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

// RelayStatus status of relay log
type RelayStatus struct {
	// upstream binlog file information
	MasterBinlog string `json:"master_binlog"`
	// GTID of the upstream
	MasterBinlogGtid string `json:"master_binlog_gtid"`
	// relay current GTID
	RelayBinlogGtid string `json:"relay_binlog_gtid"`
	// whether to catch up with upstream progress
	RelayCatchUpMaster bool `json:"relay_catch_up_master"`
	// the directory where the relay log is stored
	RelayDir string `json:"relay_dir"`
	// current status
	Stage string `json:"stage"`
}

type _RelayStatus RelayStatus

// NewRelayStatus instantiates a new RelayStatus 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 NewRelayStatus(masterBinlog string, masterBinlogGtid string, relayBinlogGtid string, relayCatchUpMaster bool, relayDir string, stage string) *RelayStatus {
	this := RelayStatus{}
	this.MasterBinlog = masterBinlog
	this.MasterBinlogGtid = masterBinlogGtid
	this.RelayBinlogGtid = relayBinlogGtid
	this.RelayCatchUpMaster = relayCatchUpMaster
	this.RelayDir = relayDir
	this.Stage = stage
	return &this
}

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

// GetMasterBinlog returns the MasterBinlog field value
func (o *RelayStatus) 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 *RelayStatus) GetMasterBinlogOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.MasterBinlog, true
}

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

// GetMasterBinlogGtid returns the MasterBinlogGtid field value
func (o *RelayStatus) 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 *RelayStatus) GetMasterBinlogGtidOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.MasterBinlogGtid, true
}

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

// GetRelayBinlogGtid returns the RelayBinlogGtid field value
func (o *RelayStatus) GetRelayBinlogGtid() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.RelayBinlogGtid
}

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

// SetRelayBinlogGtid sets field value
func (o *RelayStatus) SetRelayBinlogGtid(v string) {
	o.RelayBinlogGtid = v
}

// GetRelayCatchUpMaster returns the RelayCatchUpMaster field value
func (o *RelayStatus) GetRelayCatchUpMaster() bool {
	if o == nil {
		var ret bool
		return ret
	}

	return o.RelayCatchUpMaster
}

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

// SetRelayCatchUpMaster sets field value
func (o *RelayStatus) SetRelayCatchUpMaster(v bool) {
	o.RelayCatchUpMaster = v
}

// GetRelayDir returns the RelayDir field value
func (o *RelayStatus) GetRelayDir() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.RelayDir
}

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

// SetRelayDir sets field value
func (o *RelayStatus) SetRelayDir(v string) {
	o.RelayDir = v
}

// GetStage returns the Stage field value
func (o *RelayStatus) GetStage() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Stage
}

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

// SetStage sets field value
func (o *RelayStatus) SetStage(v string) {
	o.Stage = v
}

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

func (o RelayStatus) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["master_binlog"] = o.MasterBinlog
	toSerialize["master_binlog_gtid"] = o.MasterBinlogGtid
	toSerialize["relay_binlog_gtid"] = o.RelayBinlogGtid
	toSerialize["relay_catch_up_master"] = o.RelayCatchUpMaster
	toSerialize["relay_dir"] = o.RelayDir
	toSerialize["stage"] = o.Stage
	return toSerialize, nil
}

func (o *RelayStatus) 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{
		"master_binlog",
		"master_binlog_gtid",
		"relay_binlog_gtid",
		"relay_catch_up_master",
		"relay_dir",
		"stage",
	}

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

	varRelayStatus := _RelayStatus{}

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

	if err != nil {
		return err
	}

	*o = RelayStatus(varRelayStatus)

	return err
}

type NullableRelayStatus struct {
	value *RelayStatus
	isSet bool
}

func (v NullableRelayStatus) Get() *RelayStatus {
	return v.value
}

func (v *NullableRelayStatus) Set(val *RelayStatus) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableRelayStatus(val *RelayStatus) *NullableRelayStatus {
	return &NullableRelayStatus{value: val, isSet: true}
}

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

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