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

// SyncStatus status of sync unit
type SyncStatus struct {
	BinlogType string `json:"binlog_type"`
	// sharding DDL which current is blocking
	BlockingDdls        []string `json:"blocking_ddls"`
	DumpIoTotalBytes    int64    `json:"dump_io_total_bytes"`
	IoTotalBytes        int64    `json:"io_total_bytes"`
	MasterBinlog        string   `json:"master_binlog"`
	MasterBinlogGtid    string   `json:"master_binlog_gtid"`
	RecentTps           int64    `json:"recent_tps"`
	SecondsBehindMaster int64    `json:"seconds_behind_master"`
	Synced              bool     `json:"synced"`
	SyncerBinlog        string   `json:"syncer_binlog"`
	SyncerBinlogGtid    string   `json:"syncer_binlog_gtid"`
	TotalEvents         int64    `json:"total_events"`
	TotalTps            int64    `json:"total_tps"`
	// sharding groups which current are un-resolved
	UnresolvedGroups []ShardingGroup `json:"unresolved_groups"`
}

type _SyncStatus SyncStatus

// NewSyncStatus instantiates a new SyncStatus 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 NewSyncStatus(binlogType string, blockingDdls []string, dumpIoTotalBytes int64, ioTotalBytes int64, masterBinlog string, masterBinlogGtid string, recentTps int64, secondsBehindMaster int64, synced bool, syncerBinlog string, syncerBinlogGtid string, totalEvents int64, totalTps int64, unresolvedGroups []ShardingGroup) *SyncStatus {
	this := SyncStatus{}
	this.BinlogType = binlogType
	this.BlockingDdls = blockingDdls
	this.DumpIoTotalBytes = dumpIoTotalBytes
	this.IoTotalBytes = ioTotalBytes
	this.MasterBinlog = masterBinlog
	this.MasterBinlogGtid = masterBinlogGtid
	this.RecentTps = recentTps
	this.SecondsBehindMaster = secondsBehindMaster
	this.Synced = synced
	this.SyncerBinlog = syncerBinlog
	this.SyncerBinlogGtid = syncerBinlogGtid
	this.TotalEvents = totalEvents
	this.TotalTps = totalTps
	this.UnresolvedGroups = unresolvedGroups
	return &this
}

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

// GetBinlogType returns the BinlogType field value
func (o *SyncStatus) GetBinlogType() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.BinlogType
}

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

// SetBinlogType sets field value
func (o *SyncStatus) SetBinlogType(v string) {
	o.BinlogType = v
}

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

	return o.BlockingDdls
}

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

// SetBlockingDdls sets field value
func (o *SyncStatus) SetBlockingDdls(v []string) {
	o.BlockingDdls = v
}

// GetDumpIoTotalBytes returns the DumpIoTotalBytes field value
func (o *SyncStatus) GetDumpIoTotalBytes() int64 {
	if o == nil {
		var ret int64
		return ret
	}

	return o.DumpIoTotalBytes
}

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

// SetDumpIoTotalBytes sets field value
func (o *SyncStatus) SetDumpIoTotalBytes(v int64) {
	o.DumpIoTotalBytes = v
}

// GetIoTotalBytes returns the IoTotalBytes field value
func (o *SyncStatus) GetIoTotalBytes() int64 {
	if o == nil {
		var ret int64
		return ret
	}

	return o.IoTotalBytes
}

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

// SetIoTotalBytes sets field value
func (o *SyncStatus) SetIoTotalBytes(v int64) {
	o.IoTotalBytes = v
}

// GetMasterBinlog returns the MasterBinlog field value
func (o *SyncStatus) GetMasterBinlog() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.MasterBinlog
}

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

// SetMasterBinlog sets field value
func (o *SyncStatus) SetMasterBinlog(v string) {
	o.MasterBinlog = v
}

// GetMasterBinlogGtid returns the MasterBinlogGtid field value
func (o *SyncStatus) GetMasterBinlogGtid() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.MasterBinlogGtid
}

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

// SetMasterBinlogGtid sets field value
func (o *SyncStatus) SetMasterBinlogGtid(v string) {
	o.MasterBinlogGtid = v
}

// GetRecentTps returns the RecentTps field value
func (o *SyncStatus) GetRecentTps() int64 {
	if o == nil {
		var ret int64
		return ret
	}

	return o.RecentTps
}

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

// SetRecentTps sets field value
func (o *SyncStatus) SetRecentTps(v int64) {
	o.RecentTps = v
}

// GetSecondsBehindMaster returns the SecondsBehindMaster field value
func (o *SyncStatus) GetSecondsBehindMaster() int64 {
	if o == nil {
		var ret int64
		return ret
	}

	return o.SecondsBehindMaster
}

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

// SetSecondsBehindMaster sets field value
func (o *SyncStatus) SetSecondsBehindMaster(v int64) {
	o.SecondsBehindMaster = v
}

// GetSynced returns the Synced field value
func (o *SyncStatus) GetSynced() bool {
	if o == nil {
		var ret bool
		return ret
	}

	return o.Synced
}

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

// SetSynced sets field value
func (o *SyncStatus) SetSynced(v bool) {
	o.Synced = v
}

// GetSyncerBinlog returns the SyncerBinlog field value
func (o *SyncStatus) GetSyncerBinlog() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.SyncerBinlog
}

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

// SetSyncerBinlog sets field value
func (o *SyncStatus) SetSyncerBinlog(v string) {
	o.SyncerBinlog = v
}

// GetSyncerBinlogGtid returns the SyncerBinlogGtid field value
func (o *SyncStatus) GetSyncerBinlogGtid() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.SyncerBinlogGtid
}

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

// SetSyncerBinlogGtid sets field value
func (o *SyncStatus) SetSyncerBinlogGtid(v string) {
	o.SyncerBinlogGtid = v
}

// GetTotalEvents returns the TotalEvents field value
func (o *SyncStatus) GetTotalEvents() int64 {
	if o == nil {
		var ret int64
		return ret
	}

	return o.TotalEvents
}

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

// SetTotalEvents sets field value
func (o *SyncStatus) SetTotalEvents(v int64) {
	o.TotalEvents = v
}

// GetTotalTps returns the TotalTps field value
func (o *SyncStatus) GetTotalTps() int64 {
	if o == nil {
		var ret int64
		return ret
	}

	return o.TotalTps
}

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

// SetTotalTps sets field value
func (o *SyncStatus) SetTotalTps(v int64) {
	o.TotalTps = v
}

// GetUnresolvedGroups returns the UnresolvedGroups field value
func (o *SyncStatus) GetUnresolvedGroups() []ShardingGroup {
	if o == nil {
		var ret []ShardingGroup
		return ret
	}

	return o.UnresolvedGroups
}

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

// SetUnresolvedGroups sets field value
func (o *SyncStatus) SetUnresolvedGroups(v []ShardingGroup) {
	o.UnresolvedGroups = v
}

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

func (o SyncStatus) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["binlog_type"] = o.BinlogType
	toSerialize["blocking_ddls"] = o.BlockingDdls
	toSerialize["dump_io_total_bytes"] = o.DumpIoTotalBytes
	toSerialize["io_total_bytes"] = o.IoTotalBytes
	toSerialize["master_binlog"] = o.MasterBinlog
	toSerialize["master_binlog_gtid"] = o.MasterBinlogGtid
	toSerialize["recent_tps"] = o.RecentTps
	toSerialize["seconds_behind_master"] = o.SecondsBehindMaster
	toSerialize["synced"] = o.Synced
	toSerialize["syncer_binlog"] = o.SyncerBinlog
	toSerialize["syncer_binlog_gtid"] = o.SyncerBinlogGtid
	toSerialize["total_events"] = o.TotalEvents
	toSerialize["total_tps"] = o.TotalTps
	toSerialize["unresolved_groups"] = o.UnresolvedGroups
	return toSerialize, nil
}

func (o *SyncStatus) 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{
		"binlog_type",
		"blocking_ddls",
		"dump_io_total_bytes",
		"io_total_bytes",
		"master_binlog",
		"master_binlog_gtid",
		"recent_tps",
		"seconds_behind_master",
		"synced",
		"syncer_binlog",
		"syncer_binlog_gtid",
		"total_events",
		"total_tps",
		"unresolved_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)
		}
	}

	varSyncStatus := _SyncStatus{}

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

	if err != nil {
		return err
	}

	*o = SyncStatus(varSyncStatus)

	return err
}

type NullableSyncStatus struct {
	value *SyncStatus
	isSet bool
}

func (v NullableSyncStatus) Get() *SyncStatus {
	return v.value
}

func (v *NullableSyncStatus) Set(val *SyncStatus) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableSyncStatus(val *SyncStatus) *NullableSyncStatus {
	return &NullableSyncStatus{value: val, isSet: true}
}

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

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