/*
authentik

Making authentication simple.

API version: 2026.5.0-rc1
Contact: hello@goauthentik.io
*/

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

package api

import (
	"encoding/json"
	"fmt"
)

// checks if the RelatedGroup type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &RelatedGroup{}

// RelatedGroup Stripped down group serializer to show relevant children/parents for groups
type RelatedGroup struct {
	Pk   string `json:"pk"`
	Name string `json:"name"`
	// Users added to this group will be superusers.
	IsSuperuser          *bool                  `json:"is_superuser,omitempty"`
	Attributes           map[string]interface{} `json:"attributes,omitempty"`
	GroupUuid            string                 `json:"group_uuid"`
	AdditionalProperties map[string]interface{}
}

type _RelatedGroup RelatedGroup

// NewRelatedGroup instantiates a new RelatedGroup object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewRelatedGroup(pk string, name string, groupUuid string) *RelatedGroup {
	this := RelatedGroup{}
	this.Pk = pk
	this.Name = name
	this.GroupUuid = groupUuid
	return &this
}

// NewRelatedGroupWithDefaults instantiates a new RelatedGroup object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewRelatedGroupWithDefaults() *RelatedGroup {
	this := RelatedGroup{}
	return &this
}

// GetPk returns the Pk field value
func (o *RelatedGroup) GetPk() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Pk
}

// GetPkOk returns a tuple with the Pk field value
// and a boolean to check if the value has been set.
func (o *RelatedGroup) GetPkOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Pk, true
}

// SetPk sets field value
func (o *RelatedGroup) SetPk(v string) {
	o.Pk = v
}

// GetName returns the Name field value
func (o *RelatedGroup) GetName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Name
}

// GetNameOk returns a tuple with the Name field value
// and a boolean to check if the value has been set.
func (o *RelatedGroup) GetNameOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Name, true
}

// SetName sets field value
func (o *RelatedGroup) SetName(v string) {
	o.Name = v
}

// GetIsSuperuser returns the IsSuperuser field value if set, zero value otherwise.
func (o *RelatedGroup) GetIsSuperuser() bool {
	if o == nil || IsNil(o.IsSuperuser) {
		var ret bool
		return ret
	}
	return *o.IsSuperuser
}

// GetIsSuperuserOk returns a tuple with the IsSuperuser field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *RelatedGroup) GetIsSuperuserOk() (*bool, bool) {
	if o == nil || IsNil(o.IsSuperuser) {
		return nil, false
	}
	return o.IsSuperuser, true
}

// HasIsSuperuser returns a boolean if a field has been set.
func (o *RelatedGroup) HasIsSuperuser() bool {
	if o != nil && !IsNil(o.IsSuperuser) {
		return true
	}

	return false
}

// SetIsSuperuser gets a reference to the given bool and assigns it to the IsSuperuser field.
func (o *RelatedGroup) SetIsSuperuser(v bool) {
	o.IsSuperuser = &v
}

// GetAttributes returns the Attributes field value if set, zero value otherwise.
func (o *RelatedGroup) GetAttributes() map[string]interface{} {
	if o == nil || IsNil(o.Attributes) {
		var ret map[string]interface{}
		return ret
	}
	return o.Attributes
}

// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *RelatedGroup) GetAttributesOk() (map[string]interface{}, bool) {
	if o == nil || IsNil(o.Attributes) {
		return map[string]interface{}{}, false
	}
	return o.Attributes, true
}

// HasAttributes returns a boolean if a field has been set.
func (o *RelatedGroup) HasAttributes() bool {
	if o != nil && !IsNil(o.Attributes) {
		return true
	}

	return false
}

// SetAttributes gets a reference to the given map[string]interface{} and assigns it to the Attributes field.
func (o *RelatedGroup) SetAttributes(v map[string]interface{}) {
	o.Attributes = v
}

// GetGroupUuid returns the GroupUuid field value
func (o *RelatedGroup) GetGroupUuid() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.GroupUuid
}

// GetGroupUuidOk returns a tuple with the GroupUuid field value
// and a boolean to check if the value has been set.
func (o *RelatedGroup) GetGroupUuidOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.GroupUuid, true
}

// SetGroupUuid sets field value
func (o *RelatedGroup) SetGroupUuid(v string) {
	o.GroupUuid = v
}

func (o RelatedGroup) MarshalJSON() ([]byte, error) {
	toSerialize, err := o.ToMap()
	if err != nil {
		return []byte{}, err
	}
	return json.Marshal(toSerialize)
}

func (o RelatedGroup) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["pk"] = o.Pk
	toSerialize["name"] = o.Name
	if !IsNil(o.IsSuperuser) {
		toSerialize["is_superuser"] = o.IsSuperuser
	}
	if !IsNil(o.Attributes) {
		toSerialize["attributes"] = o.Attributes
	}
	toSerialize["group_uuid"] = o.GroupUuid

	for key, value := range o.AdditionalProperties {
		toSerialize[key] = value
	}

	return toSerialize, nil
}

func (o *RelatedGroup) UnmarshalJSON(data []byte) (err error) {
	// This validates that all required properties are included in the JSON object
	// by unmarshalling the object into a generic map with string keys and checking
	// that every required field exists as a key in the generic map.
	requiredProperties := []string{
		"pk",
		"name",
		"group_uuid",
	}

	allProperties := make(map[string]interface{})

	err = json.Unmarshal(data, &allProperties)

	if err != nil {
		return err
	}

	for _, requiredProperty := range requiredProperties {
		if _, exists := allProperties[requiredProperty]; !exists {
			return fmt.Errorf("no value given for required property %v", requiredProperty)
		}
	}

	varRelatedGroup := _RelatedGroup{}

	err = json.Unmarshal(data, &varRelatedGroup)

	if err != nil {
		return err
	}

	*o = RelatedGroup(varRelatedGroup)

	additionalProperties := make(map[string]interface{})

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "pk")
		delete(additionalProperties, "name")
		delete(additionalProperties, "is_superuser")
		delete(additionalProperties, "attributes")
		delete(additionalProperties, "group_uuid")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableRelatedGroup struct {
	value *RelatedGroup
	isSet bool
}

func (v NullableRelatedGroup) Get() *RelatedGroup {
	return v.value
}

func (v *NullableRelatedGroup) Set(val *RelatedGroup) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableRelatedGroup(val *RelatedGroup) *NullableRelatedGroup {
	return &NullableRelatedGroup{value: val, isSet: true}
}

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

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