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

// LoadStatus status of load unit
type LoadStatus struct {
	Bps            int64  `json:"bps"`
	FinishedBytes  int64  `json:"finished_bytes"`
	MetaBinlog     string `json:"meta_binlog"`
	MetaBinlogGtid string `json:"meta_binlog_gtid"`
	Progress       string `json:"progress"`
	TotalBytes     int64  `json:"total_bytes"`
}

type _LoadStatus LoadStatus

// NewLoadStatus instantiates a new LoadStatus 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 NewLoadStatus(bps int64, finishedBytes int64, metaBinlog string, metaBinlogGtid string, progress string, totalBytes int64) *LoadStatus {
	this := LoadStatus{}
	this.Bps = bps
	this.FinishedBytes = finishedBytes
	this.MetaBinlog = metaBinlog
	this.MetaBinlogGtid = metaBinlogGtid
	this.Progress = progress
	this.TotalBytes = totalBytes
	return &this
}

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

// GetBps returns the Bps field value
func (o *LoadStatus) GetBps() int64 {
	if o == nil {
		var ret int64
		return ret
	}

	return o.Bps
}

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

// SetBps sets field value
func (o *LoadStatus) SetBps(v int64) {
	o.Bps = v
}

// GetFinishedBytes returns the FinishedBytes field value
func (o *LoadStatus) GetFinishedBytes() int64 {
	if o == nil {
		var ret int64
		return ret
	}

	return o.FinishedBytes
}

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

// SetFinishedBytes sets field value
func (o *LoadStatus) SetFinishedBytes(v int64) {
	o.FinishedBytes = v
}

// GetMetaBinlog returns the MetaBinlog field value
func (o *LoadStatus) GetMetaBinlog() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.MetaBinlog
}

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

// SetMetaBinlog sets field value
func (o *LoadStatus) SetMetaBinlog(v string) {
	o.MetaBinlog = v
}

// GetMetaBinlogGtid returns the MetaBinlogGtid field value
func (o *LoadStatus) GetMetaBinlogGtid() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.MetaBinlogGtid
}

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

// SetMetaBinlogGtid sets field value
func (o *LoadStatus) SetMetaBinlogGtid(v string) {
	o.MetaBinlogGtid = v
}

// GetProgress returns the Progress field value
func (o *LoadStatus) GetProgress() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Progress
}

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

// SetProgress sets field value
func (o *LoadStatus) SetProgress(v string) {
	o.Progress = v
}

// GetTotalBytes returns the TotalBytes field value
func (o *LoadStatus) GetTotalBytes() int64 {
	if o == nil {
		var ret int64
		return ret
	}

	return o.TotalBytes
}

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

// SetTotalBytes sets field value
func (o *LoadStatus) SetTotalBytes(v int64) {
	o.TotalBytes = v
}

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

func (o LoadStatus) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["bps"] = o.Bps
	toSerialize["finished_bytes"] = o.FinishedBytes
	toSerialize["meta_binlog"] = o.MetaBinlog
	toSerialize["meta_binlog_gtid"] = o.MetaBinlogGtid
	toSerialize["progress"] = o.Progress
	toSerialize["total_bytes"] = o.TotalBytes
	return toSerialize, nil
}

func (o *LoadStatus) 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{
		"bps",
		"finished_bytes",
		"meta_binlog",
		"meta_binlog_gtid",
		"progress",
		"total_bytes",
	}

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

	varLoadStatus := _LoadStatus{}

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

	if err != nil {
		return err
	}

	*o = LoadStatus(varLoadStatus)

	return err
}

type NullableLoadStatus struct {
	value *LoadStatus
	isSet bool
}

func (v NullableLoadStatus) Get() *LoadStatus {
	return v.value
}

func (v *NullableLoadStatus) Set(val *LoadStatus) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableLoadStatus(val *LoadStatus) *NullableLoadStatus {
	return &NullableLoadStatus{value: val, isSet: true}
}

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

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