/*
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"
	"bytes"
	"fmt"
)

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

// Groups struct for Groups
type Groups struct {
	// List of device's groups.
	Groups []string `json:"groups"`
}

type _Groups Groups

// NewGroups instantiates a new Groups 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 NewGroups(groups []string) *Groups {
	this := Groups{}
	this.Groups = groups
	return &this
}

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

// GetGroups returns the Groups field value
func (o *Groups) GetGroups() []string {
	if o == nil {
		var ret []string
		return ret
	}

	return o.Groups
}

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

// SetGroups sets field value
func (o *Groups) SetGroups(v []string) {
	o.Groups = v
}

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

func (o Groups) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["groups"] = o.Groups
	return toSerialize, nil
}

func (o *Groups) 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{
		"groups",
	}

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

	varGroups := _Groups{}

	decoder := json.NewDecoder(bytes.NewReader(data))
	decoder.DisallowUnknownFields()
	err = decoder.Decode(&varGroups)

	if err != nil {
		return err
	}

	*o = Groups(varGroups)

	return err
}

type NullableGroups struct {
	value *Groups
	isSet bool
}

func (v NullableGroups) Get() *Groups {
	return v.value
}

func (v *NullableGroups) Set(val *Groups) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableGroups(val *Groups) *NullableGroups {
	return &NullableGroups{value: val, isSet: true}
}

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

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


