/*
DM OpenAPI DOC

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

API version: 6.0.0
*/

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

package dm

import (
	"bytes"
	"encoding/json"
	"fmt"
)

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

// UpdateSourceRequest struct for UpdateSourceRequest
type UpdateSourceRequest struct {
	Source Source `json:"source"`
}

type _UpdateSourceRequest UpdateSourceRequest

// NewUpdateSourceRequest instantiates a new UpdateSourceRequest 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 NewUpdateSourceRequest(source Source) *UpdateSourceRequest {
	this := UpdateSourceRequest{}
	this.Source = source
	return &this
}

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

// GetSource returns the Source field value
func (o *UpdateSourceRequest) GetSource() Source {
	if o == nil {
		var ret Source
		return ret
	}

	return o.Source
}

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

// SetSource sets field value
func (o *UpdateSourceRequest) SetSource(v Source) {
	o.Source = v
}

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

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

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

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

	varUpdateSourceRequest := _UpdateSourceRequest{}

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

	if err != nil {
		return err
	}

	*o = UpdateSourceRequest(varUpdateSourceRequest)

	return err
}

type NullableUpdateSourceRequest struct {
	value *UpdateSourceRequest
	isSet bool
}

func (v NullableUpdateSourceRequest) Get() *UpdateSourceRequest {
	return v.value
}

func (v *NullableUpdateSourceRequest) Set(val *UpdateSourceRequest) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableUpdateSourceRequest(val *UpdateSourceRequest) *NullableUpdateSourceRequest {
	return &NullableUpdateSourceRequest{value: val, isSet: true}
}

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

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