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

// TaskSourceConf struct for TaskSourceConf
type TaskSourceConf struct {
	BinlogGtid *string `json:"binlog_gtid,omitempty"`
	BinlogName *string `json:"binlog_name,omitempty"`
	BinlogPos  *int32  `json:"binlog_pos,omitempty"`
	// source name
	SourceName string `json:"source_name"`
}

type _TaskSourceConf TaskSourceConf

// NewTaskSourceConf instantiates a new TaskSourceConf 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 NewTaskSourceConf(sourceName string) *TaskSourceConf {
	this := TaskSourceConf{}
	this.SourceName = sourceName
	return &this
}

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

// GetBinlogGtid returns the BinlogGtid field value if set, zero value otherwise.
func (o *TaskSourceConf) GetBinlogGtid() string {
	if o == nil || IsNil(o.BinlogGtid) {
		var ret string
		return ret
	}
	return *o.BinlogGtid
}

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

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

	return false
}

// SetBinlogGtid gets a reference to the given string and assigns it to the BinlogGtid field.
func (o *TaskSourceConf) SetBinlogGtid(v string) {
	o.BinlogGtid = &v
}

// GetBinlogName returns the BinlogName field value if set, zero value otherwise.
func (o *TaskSourceConf) GetBinlogName() string {
	if o == nil || IsNil(o.BinlogName) {
		var ret string
		return ret
	}
	return *o.BinlogName
}

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

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

	return false
}

// SetBinlogName gets a reference to the given string and assigns it to the BinlogName field.
func (o *TaskSourceConf) SetBinlogName(v string) {
	o.BinlogName = &v
}

// GetBinlogPos returns the BinlogPos field value if set, zero value otherwise.
func (o *TaskSourceConf) GetBinlogPos() int32 {
	if o == nil || IsNil(o.BinlogPos) {
		var ret int32
		return ret
	}
	return *o.BinlogPos
}

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

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

	return false
}

// SetBinlogPos gets a reference to the given int32 and assigns it to the BinlogPos field.
func (o *TaskSourceConf) SetBinlogPos(v int32) {
	o.BinlogPos = &v
}

// GetSourceName returns the SourceName field value
func (o *TaskSourceConf) GetSourceName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.SourceName
}

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

// SetSourceName sets field value
func (o *TaskSourceConf) SetSourceName(v string) {
	o.SourceName = v
}

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

func (o TaskSourceConf) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.BinlogGtid) {
		toSerialize["binlog_gtid"] = o.BinlogGtid
	}
	if !IsNil(o.BinlogName) {
		toSerialize["binlog_name"] = o.BinlogName
	}
	if !IsNil(o.BinlogPos) {
		toSerialize["binlog_pos"] = o.BinlogPos
	}
	toSerialize["source_name"] = o.SourceName
	return toSerialize, nil
}

func (o *TaskSourceConf) 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_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)
		}
	}

	varTaskSourceConf := _TaskSourceConf{}

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

	if err != nil {
		return err
	}

	*o = TaskSourceConf(varTaskSourceConf)

	return err
}

type NullableTaskSourceConf struct {
	value *TaskSourceConf
	isSet bool
}

func (v NullableTaskSourceConf) Get() *TaskSourceConf {
	return v.value
}

func (v *NullableTaskSourceConf) Set(val *TaskSourceConf) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableTaskSourceConf(val *TaskSourceConf) *NullableTaskSourceConf {
	return &NullableTaskSourceConf{value: val, isSet: true}
}

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

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