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

// ClusterWorker struct for ClusterWorker
type ClusterWorker struct {
	// address of the current master node
	Addr string `json:"addr"`
	// source name bound to this worker node
	BoundSourceName string `json:"bound_source_name"`
	// bound stage of this worker node
	BoundStage string `json:"bound_stage"`
	Name       string `json:"name"`
}

type _ClusterWorker ClusterWorker

// NewClusterWorker instantiates a new ClusterWorker 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 NewClusterWorker(addr string, boundSourceName string, boundStage string, name string) *ClusterWorker {
	this := ClusterWorker{}
	this.Addr = addr
	this.BoundSourceName = boundSourceName
	this.BoundStage = boundStage
	this.Name = name
	return &this
}

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

// GetAddr returns the Addr field value
func (o *ClusterWorker) GetAddr() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Addr
}

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

// SetAddr sets field value
func (o *ClusterWorker) SetAddr(v string) {
	o.Addr = v
}

// GetBoundSourceName returns the BoundSourceName field value
func (o *ClusterWorker) GetBoundSourceName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.BoundSourceName
}

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

// SetBoundSourceName sets field value
func (o *ClusterWorker) SetBoundSourceName(v string) {
	o.BoundSourceName = v
}

// GetBoundStage returns the BoundStage field value
func (o *ClusterWorker) GetBoundStage() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.BoundStage
}

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

// SetBoundStage sets field value
func (o *ClusterWorker) SetBoundStage(v string) {
	o.BoundStage = v
}

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

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

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

func (o ClusterWorker) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["addr"] = o.Addr
	toSerialize["bound_source_name"] = o.BoundSourceName
	toSerialize["bound_stage"] = o.BoundStage
	toSerialize["name"] = o.Name
	return toSerialize, nil
}

func (o *ClusterWorker) 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{
		"addr",
		"bound_source_name",
		"bound_stage",
		"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)
		}
	}

	varClusterWorker := _ClusterWorker{}

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

	if err != nil {
		return err
	}

	*o = ClusterWorker(varClusterWorker)

	return err
}

type NullableClusterWorker struct {
	value *ClusterWorker
	isSet bool
}

func (v NullableClusterWorker) Get() *ClusterWorker {
	return v.value
}

func (v *NullableClusterWorker) Set(val *ClusterWorker) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableClusterWorker(val *ClusterWorker) *NullableClusterWorker {
	return &NullableClusterWorker{value: val, isSet: true}
}

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

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