/*
Merlin

API Guide for accessing Merlin's model management, deployment, and serving functionalities

API version: 0.14.0
*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

package client

import (
	"encoding/json"
	"fmt"
)

// checks if the SchemaSpec type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &SchemaSpec{}

// SchemaSpec struct for SchemaSpec
type SchemaSpec struct {
	SessionIdColumn       *string               `json:"session_id_column,omitempty"`
	RowIdColumn           *string               `json:"row_id_column,omitempty"`
	ModelPredictionOutput ModelPredictionOutput `json:"model_prediction_output"`
	TagColumns            []string              `json:"tag_columns,omitempty"`
	FeatureTypes          map[string]ValueType  `json:"feature_types"`
	FeatureOrders         []string              `json:"feature_orders,omitempty"`
}

type _SchemaSpec SchemaSpec

// NewSchemaSpec instantiates a new SchemaSpec 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 NewSchemaSpec(modelPredictionOutput ModelPredictionOutput, featureTypes map[string]ValueType) *SchemaSpec {
	this := SchemaSpec{}
	this.ModelPredictionOutput = modelPredictionOutput
	this.FeatureTypes = featureTypes
	return &this
}

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

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

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

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

	return false
}

// SetSessionIdColumn gets a reference to the given string and assigns it to the SessionIdColumn field.
func (o *SchemaSpec) SetSessionIdColumn(v string) {
	o.SessionIdColumn = &v
}

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

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

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

	return false
}

// SetRowIdColumn gets a reference to the given string and assigns it to the RowIdColumn field.
func (o *SchemaSpec) SetRowIdColumn(v string) {
	o.RowIdColumn = &v
}

// GetModelPredictionOutput returns the ModelPredictionOutput field value
func (o *SchemaSpec) GetModelPredictionOutput() ModelPredictionOutput {
	if o == nil {
		var ret ModelPredictionOutput
		return ret
	}

	return o.ModelPredictionOutput
}

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

// SetModelPredictionOutput sets field value
func (o *SchemaSpec) SetModelPredictionOutput(v ModelPredictionOutput) {
	o.ModelPredictionOutput = v
}

// GetTagColumns returns the TagColumns field value if set, zero value otherwise.
func (o *SchemaSpec) GetTagColumns() []string {
	if o == nil || IsNil(o.TagColumns) {
		var ret []string
		return ret
	}
	return o.TagColumns
}

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

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

	return false
}

// SetTagColumns gets a reference to the given []string and assigns it to the TagColumns field.
func (o *SchemaSpec) SetTagColumns(v []string) {
	o.TagColumns = v
}

// GetFeatureTypes returns the FeatureTypes field value
func (o *SchemaSpec) GetFeatureTypes() map[string]ValueType {
	if o == nil {
		var ret map[string]ValueType
		return ret
	}

	return o.FeatureTypes
}

// GetFeatureTypesOk returns a tuple with the FeatureTypes field value
// and a boolean to check if the value has been set.
func (o *SchemaSpec) GetFeatureTypesOk() (*map[string]ValueType, bool) {
	if o == nil {
		return nil, false
	}
	return &o.FeatureTypes, true
}

// SetFeatureTypes sets field value
func (o *SchemaSpec) SetFeatureTypes(v map[string]ValueType) {
	o.FeatureTypes = v
}

// GetFeatureOrders returns the FeatureOrders field value if set, zero value otherwise.
func (o *SchemaSpec) GetFeatureOrders() []string {
	if o == nil || IsNil(o.FeatureOrders) {
		var ret []string
		return ret
	}
	return o.FeatureOrders
}

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

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

	return false
}

// SetFeatureOrders gets a reference to the given []string and assigns it to the FeatureOrders field.
func (o *SchemaSpec) SetFeatureOrders(v []string) {
	o.FeatureOrders = v
}

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

func (o SchemaSpec) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.SessionIdColumn) {
		toSerialize["session_id_column"] = o.SessionIdColumn
	}
	if !IsNil(o.RowIdColumn) {
		toSerialize["row_id_column"] = o.RowIdColumn
	}
	toSerialize["model_prediction_output"] = o.ModelPredictionOutput
	if !IsNil(o.TagColumns) {
		toSerialize["tag_columns"] = o.TagColumns
	}
	toSerialize["feature_types"] = o.FeatureTypes
	if !IsNil(o.FeatureOrders) {
		toSerialize["feature_orders"] = o.FeatureOrders
	}
	return toSerialize, nil
}

func (o *SchemaSpec) UnmarshalJSON(bytes []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{
		"model_prediction_output",
		"feature_types",
	}

	allProperties := make(map[string]interface{})

	err = json.Unmarshal(bytes, &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)
		}
	}

	varSchemaSpec := _SchemaSpec{}

	err = json.Unmarshal(bytes, &varSchemaSpec)

	if err != nil {
		return err
	}

	*o = SchemaSpec(varSchemaSpec)

	return err
}

type NullableSchemaSpec struct {
	value *SchemaSpec
	isSet bool
}

func (v NullableSchemaSpec) Get() *SchemaSpec {
	return v.value
}

func (v *NullableSchemaSpec) Set(val *SchemaSpec) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableSchemaSpec(val *SchemaSpec) *NullableSchemaSpec {
	return &NullableSchemaSpec{value: val, isSet: true}
}

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

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