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

// TaskMigrateTarget task migrate targets
type TaskMigrateTarget struct {
	SourceSchema string `json:"source_schema"`
	SourceTable  string `json:"source_table"`
	TargetSchema string `json:"target_schema"`
	TargetTable  string `json:"target_table"`
}

type _TaskMigrateTarget TaskMigrateTarget

// NewTaskMigrateTarget instantiates a new TaskMigrateTarget 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 NewTaskMigrateTarget(sourceSchema string, sourceTable string, targetSchema string, targetTable string) *TaskMigrateTarget {
	this := TaskMigrateTarget{}
	this.SourceSchema = sourceSchema
	this.SourceTable = sourceTable
	this.TargetSchema = targetSchema
	this.TargetTable = targetTable
	return &this
}

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

// GetSourceSchema returns the SourceSchema field value
func (o *TaskMigrateTarget) GetSourceSchema() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.SourceSchema
}

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

// SetSourceSchema sets field value
func (o *TaskMigrateTarget) SetSourceSchema(v string) {
	o.SourceSchema = v
}

// GetSourceTable returns the SourceTable field value
func (o *TaskMigrateTarget) GetSourceTable() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.SourceTable
}

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

// SetSourceTable sets field value
func (o *TaskMigrateTarget) SetSourceTable(v string) {
	o.SourceTable = v
}

// GetTargetSchema returns the TargetSchema field value
func (o *TaskMigrateTarget) GetTargetSchema() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.TargetSchema
}

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

// SetTargetSchema sets field value
func (o *TaskMigrateTarget) SetTargetSchema(v string) {
	o.TargetSchema = v
}

// GetTargetTable returns the TargetTable field value
func (o *TaskMigrateTarget) GetTargetTable() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.TargetTable
}

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

// SetTargetTable sets field value
func (o *TaskMigrateTarget) SetTargetTable(v string) {
	o.TargetTable = v
}

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

func (o TaskMigrateTarget) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["source_schema"] = o.SourceSchema
	toSerialize["source_table"] = o.SourceTable
	toSerialize["target_schema"] = o.TargetSchema
	toSerialize["target_table"] = o.TargetTable
	return toSerialize, nil
}

func (o *TaskMigrateTarget) 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_schema",
		"source_table",
		"target_schema",
		"target_table",
	}

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

	varTaskMigrateTarget := _TaskMigrateTarget{}

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

	if err != nil {
		return err
	}

	*o = TaskMigrateTarget(varTaskMigrateTarget)

	return err
}

type NullableTaskMigrateTarget struct {
	value *TaskMigrateTarget
	isSet bool
}

func (v NullableTaskMigrateTarget) Get() *TaskMigrateTarget {
	return v.value
}

func (v *NullableTaskMigrateTarget) Set(val *TaskMigrateTarget) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableTaskMigrateTarget(val *TaskMigrateTarget) *NullableTaskMigrateTarget {
	return &NullableTaskMigrateTarget{value: val, isSet: true}
}

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

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