/*
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 PartialGroup type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &PartialGroup{}

// PartialGroup Partial Group Serializer, does not include child relations.
type PartialGroup struct {
	Pk string `json:"pk"`
	// Get a numerical, int32 ID for the group
	NumPk int32  `json:"num_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"`
	AdditionalProperties map[string]interface{}
}

type _PartialGroup PartialGroup

// NewPartialGroup instantiates a new PartialGroup 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 NewPartialGroup(pk string, numPk int32, name string) *PartialGroup {
	this := PartialGroup{}
	this.Pk = pk
	this.NumPk = numPk
	this.Name = name
	return &this
}

// NewPartialGroupWithDefaults instantiates a new PartialGroup 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 NewPartialGroupWithDefaults() *PartialGroup {
	this := PartialGroup{}
	return &this
}

// GetPk returns the Pk field value
func (o *PartialGroup) 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 *PartialGroup) GetPkOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Pk, true
}

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

// GetNumPk returns the NumPk field value
func (o *PartialGroup) GetNumPk() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.NumPk
}

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

// SetNumPk sets field value
func (o *PartialGroup) SetNumPk(v int32) {
	o.NumPk = v
}

// GetName returns the Name field value
func (o *PartialGroup) 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 *PartialGroup) GetNameOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Name, true
}

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

// GetIsSuperuser returns the IsSuperuser field value if set, zero value otherwise.
func (o *PartialGroup) 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 *PartialGroup) 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 *PartialGroup) 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 *PartialGroup) SetIsSuperuser(v bool) {
	o.IsSuperuser = &v
}

// GetAttributes returns the Attributes field value if set, zero value otherwise.
func (o *PartialGroup) 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 *PartialGroup) 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 *PartialGroup) 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 *PartialGroup) SetAttributes(v map[string]interface{}) {
	o.Attributes = v
}

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

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

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

	return toSerialize, nil
}

func (o *PartialGroup) 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",
		"num_pk",
		"name",
	}

	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)
		}
	}

	varPartialGroup := _PartialGroup{}

	err = json.Unmarshal(data, &varPartialGroup)

	if err != nil {
		return err
	}

	*o = PartialGroup(varPartialGroup)

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

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

	return err
}

type NullablePartialGroup struct {
	value *PartialGroup
	isSet bool
}

func (v NullablePartialGroup) Get() *PartialGroup {
	return v.value
}

func (v *NullablePartialGroup) Set(val *PartialGroup) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullablePartialGroup(val *PartialGroup) *NullablePartialGroup {
	return &NullablePartialGroup{value: val, isSet: true}
}

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

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