/*
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"
	"time"
)

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

// Model struct for Model
type Model struct {
	Id                 *int32 `json:"id,omitempty"`
	ProjectId          *int32 `json:"project_id,omitempty"`
	MlflowExperimentId *int32 `json:"mlflow_experiment_id,omitempty"`
	Name               string `json:"name"`
	// Model type
	Type      *string         `json:"type,omitempty"`
	MlflowUrl *string         `json:"mlflow_url,omitempty"`
	Endpoints []ModelEndpoint `json:"endpoints,omitempty"`
	CreatedAt *time.Time      `json:"created_at,omitempty"`
	UpdatedAt *time.Time      `json:"updated_at,omitempty"`
}

type _Model Model

// NewModel instantiates a new Model 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 NewModel(name string) *Model {
	this := Model{}
	this.Name = name
	return &this
}

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

// GetId returns the Id field value if set, zero value otherwise.
func (o *Model) GetId() int32 {
	if o == nil || IsNil(o.Id) {
		var ret int32
		return ret
	}
	return *o.Id
}

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

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

	return false
}

// SetId gets a reference to the given int32 and assigns it to the Id field.
func (o *Model) SetId(v int32) {
	o.Id = &v
}

// GetProjectId returns the ProjectId field value if set, zero value otherwise.
func (o *Model) GetProjectId() int32 {
	if o == nil || IsNil(o.ProjectId) {
		var ret int32
		return ret
	}
	return *o.ProjectId
}

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

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

	return false
}

// SetProjectId gets a reference to the given int32 and assigns it to the ProjectId field.
func (o *Model) SetProjectId(v int32) {
	o.ProjectId = &v
}

// GetMlflowExperimentId returns the MlflowExperimentId field value if set, zero value otherwise.
func (o *Model) GetMlflowExperimentId() int32 {
	if o == nil || IsNil(o.MlflowExperimentId) {
		var ret int32
		return ret
	}
	return *o.MlflowExperimentId
}

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

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

	return false
}

// SetMlflowExperimentId gets a reference to the given int32 and assigns it to the MlflowExperimentId field.
func (o *Model) SetMlflowExperimentId(v int32) {
	o.MlflowExperimentId = &v
}

// GetName returns the Name field value
func (o *Model) GetName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Name
}

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

// SetName sets field value
func (o *Model) SetName(v string) {
	o.Name = v
}

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

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

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

	return false
}

// SetType gets a reference to the given string and assigns it to the Type field.
func (o *Model) SetType(v string) {
	o.Type = &v
}

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

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

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

	return false
}

// SetMlflowUrl gets a reference to the given string and assigns it to the MlflowUrl field.
func (o *Model) SetMlflowUrl(v string) {
	o.MlflowUrl = &v
}

// GetEndpoints returns the Endpoints field value if set, zero value otherwise.
func (o *Model) GetEndpoints() []ModelEndpoint {
	if o == nil || IsNil(o.Endpoints) {
		var ret []ModelEndpoint
		return ret
	}
	return o.Endpoints
}

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

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

	return false
}

// SetEndpoints gets a reference to the given []ModelEndpoint and assigns it to the Endpoints field.
func (o *Model) SetEndpoints(v []ModelEndpoint) {
	o.Endpoints = v
}

// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise.
func (o *Model) GetCreatedAt() time.Time {
	if o == nil || IsNil(o.CreatedAt) {
		var ret time.Time
		return ret
	}
	return *o.CreatedAt
}

// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Model) GetCreatedAtOk() (*time.Time, bool) {
	if o == nil || IsNil(o.CreatedAt) {
		return nil, false
	}
	return o.CreatedAt, true
}

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

	return false
}

// SetCreatedAt gets a reference to the given time.Time and assigns it to the CreatedAt field.
func (o *Model) SetCreatedAt(v time.Time) {
	o.CreatedAt = &v
}

// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise.
func (o *Model) GetUpdatedAt() time.Time {
	if o == nil || IsNil(o.UpdatedAt) {
		var ret time.Time
		return ret
	}
	return *o.UpdatedAt
}

// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Model) GetUpdatedAtOk() (*time.Time, bool) {
	if o == nil || IsNil(o.UpdatedAt) {
		return nil, false
	}
	return o.UpdatedAt, true
}

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

	return false
}

// SetUpdatedAt gets a reference to the given time.Time and assigns it to the UpdatedAt field.
func (o *Model) SetUpdatedAt(v time.Time) {
	o.UpdatedAt = &v
}

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

func (o Model) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Id) {
		toSerialize["id"] = o.Id
	}
	if !IsNil(o.ProjectId) {
		toSerialize["project_id"] = o.ProjectId
	}
	if !IsNil(o.MlflowExperimentId) {
		toSerialize["mlflow_experiment_id"] = o.MlflowExperimentId
	}
	toSerialize["name"] = o.Name
	if !IsNil(o.Type) {
		toSerialize["type"] = o.Type
	}
	if !IsNil(o.MlflowUrl) {
		toSerialize["mlflow_url"] = o.MlflowUrl
	}
	if !IsNil(o.Endpoints) {
		toSerialize["endpoints"] = o.Endpoints
	}
	if !IsNil(o.CreatedAt) {
		toSerialize["created_at"] = o.CreatedAt
	}
	if !IsNil(o.UpdatedAt) {
		toSerialize["updated_at"] = o.UpdatedAt
	}
	return toSerialize, nil
}

func (o *Model) 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{
		"name",
	}

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

	varModel := _Model{}

	err = json.Unmarshal(bytes, &varModel)

	if err != nil {
		return err
	}

	*o = Model(varModel)

	return err
}

type NullableModel struct {
	value *Model
	isSet bool
}

func (v NullableModel) Get() *Model {
	return v.value
}

func (v *NullableModel) Set(val *Model) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableModel(val *Model) *NullableModel {
	return &NullableModel{value: val, isSet: true}
}

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

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