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

// Environment struct for Environment
type Environment struct {
	Id                                  *int32                        `json:"id,omitempty"`
	Name                                string                        `json:"name"`
	Cluster                             string                        `json:"cluster"`
	IsDefault                           *bool                         `json:"is_default,omitempty"`
	Region                              *string                       `json:"region,omitempty"`
	GcpProject                          *string                       `json:"gcp_project,omitempty"`
	DefaultResourceRequest              *ResourceRequest              `json:"default_resource_request,omitempty"`
	DefaultTransformerResourceRequest   *ResourceRequest              `json:"default_transformer_resource_request,omitempty"`
	DefaultPredictionJobResourceRequest *PredictionJobResourceRequest `json:"default_prediction_job_resource_request,omitempty"`
	Gpus                                []GPUConfig                   `json:"gpus,omitempty"`
	CreatedAt                           *time.Time                    `json:"created_at,omitempty"`
	UpdatedAt                           *time.Time                    `json:"updated_at,omitempty"`
}

type _Environment Environment

// NewEnvironment instantiates a new Environment 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 NewEnvironment(name string, cluster string) *Environment {
	this := Environment{}
	this.Name = name
	this.Cluster = cluster
	return &this
}

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

// GetId returns the Id field value if set, zero value otherwise.
func (o *Environment) 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 *Environment) 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 *Environment) 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 *Environment) SetId(v int32) {
	o.Id = &v
}

// GetName returns the Name field value
func (o *Environment) 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 *Environment) GetNameOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Name, true
}

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

// GetCluster returns the Cluster field value
func (o *Environment) GetCluster() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Cluster
}

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

// SetCluster sets field value
func (o *Environment) SetCluster(v string) {
	o.Cluster = v
}

// GetIsDefault returns the IsDefault field value if set, zero value otherwise.
func (o *Environment) GetIsDefault() bool {
	if o == nil || IsNil(o.IsDefault) {
		var ret bool
		return ret
	}
	return *o.IsDefault
}

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

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

	return false
}

// SetIsDefault gets a reference to the given bool and assigns it to the IsDefault field.
func (o *Environment) SetIsDefault(v bool) {
	o.IsDefault = &v
}

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

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

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

	return false
}

// SetRegion gets a reference to the given string and assigns it to the Region field.
func (o *Environment) SetRegion(v string) {
	o.Region = &v
}

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

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

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

	return false
}

// SetGcpProject gets a reference to the given string and assigns it to the GcpProject field.
func (o *Environment) SetGcpProject(v string) {
	o.GcpProject = &v
}

// GetDefaultResourceRequest returns the DefaultResourceRequest field value if set, zero value otherwise.
func (o *Environment) GetDefaultResourceRequest() ResourceRequest {
	if o == nil || IsNil(o.DefaultResourceRequest) {
		var ret ResourceRequest
		return ret
	}
	return *o.DefaultResourceRequest
}

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

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

	return false
}

// SetDefaultResourceRequest gets a reference to the given ResourceRequest and assigns it to the DefaultResourceRequest field.
func (o *Environment) SetDefaultResourceRequest(v ResourceRequest) {
	o.DefaultResourceRequest = &v
}

// GetDefaultTransformerResourceRequest returns the DefaultTransformerResourceRequest field value if set, zero value otherwise.
func (o *Environment) GetDefaultTransformerResourceRequest() ResourceRequest {
	if o == nil || IsNil(o.DefaultTransformerResourceRequest) {
		var ret ResourceRequest
		return ret
	}
	return *o.DefaultTransformerResourceRequest
}

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

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

	return false
}

// SetDefaultTransformerResourceRequest gets a reference to the given ResourceRequest and assigns it to the DefaultTransformerResourceRequest field.
func (o *Environment) SetDefaultTransformerResourceRequest(v ResourceRequest) {
	o.DefaultTransformerResourceRequest = &v
}

// GetDefaultPredictionJobResourceRequest returns the DefaultPredictionJobResourceRequest field value if set, zero value otherwise.
func (o *Environment) GetDefaultPredictionJobResourceRequest() PredictionJobResourceRequest {
	if o == nil || IsNil(o.DefaultPredictionJobResourceRequest) {
		var ret PredictionJobResourceRequest
		return ret
	}
	return *o.DefaultPredictionJobResourceRequest
}

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

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

	return false
}

// SetDefaultPredictionJobResourceRequest gets a reference to the given PredictionJobResourceRequest and assigns it to the DefaultPredictionJobResourceRequest field.
func (o *Environment) SetDefaultPredictionJobResourceRequest(v PredictionJobResourceRequest) {
	o.DefaultPredictionJobResourceRequest = &v
}

// GetGpus returns the Gpus field value if set, zero value otherwise.
func (o *Environment) GetGpus() []GPUConfig {
	if o == nil || IsNil(o.Gpus) {
		var ret []GPUConfig
		return ret
	}
	return o.Gpus
}

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

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

	return false
}

// SetGpus gets a reference to the given []GPUConfig and assigns it to the Gpus field.
func (o *Environment) SetGpus(v []GPUConfig) {
	o.Gpus = v
}

// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise.
func (o *Environment) 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 *Environment) 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 *Environment) 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 *Environment) SetCreatedAt(v time.Time) {
	o.CreatedAt = &v
}

// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise.
func (o *Environment) 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 *Environment) 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 *Environment) 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 *Environment) SetUpdatedAt(v time.Time) {
	o.UpdatedAt = &v
}

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

func (o Environment) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Id) {
		toSerialize["id"] = o.Id
	}
	toSerialize["name"] = o.Name
	toSerialize["cluster"] = o.Cluster
	if !IsNil(o.IsDefault) {
		toSerialize["is_default"] = o.IsDefault
	}
	if !IsNil(o.Region) {
		toSerialize["region"] = o.Region
	}
	if !IsNil(o.GcpProject) {
		toSerialize["gcp_project"] = o.GcpProject
	}
	if !IsNil(o.DefaultResourceRequest) {
		toSerialize["default_resource_request"] = o.DefaultResourceRequest
	}
	if !IsNil(o.DefaultTransformerResourceRequest) {
		toSerialize["default_transformer_resource_request"] = o.DefaultTransformerResourceRequest
	}
	if !IsNil(o.DefaultPredictionJobResourceRequest) {
		toSerialize["default_prediction_job_resource_request"] = o.DefaultPredictionJobResourceRequest
	}
	if !IsNil(o.Gpus) {
		toSerialize["gpus"] = o.Gpus
	}
	if !IsNil(o.CreatedAt) {
		toSerialize["created_at"] = o.CreatedAt
	}
	if !IsNil(o.UpdatedAt) {
		toSerialize["updated_at"] = o.UpdatedAt
	}
	return toSerialize, nil
}

func (o *Environment) 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",
		"cluster",
	}

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

	varEnvironment := _Environment{}

	err = json.Unmarshal(bytes, &varEnvironment)

	if err != nil {
		return err
	}

	*o = Environment(varEnvironment)

	return err
}

type NullableEnvironment struct {
	value *Environment
	isSet bool
}

func (v NullableEnvironment) Get() *Environment {
	return v.value
}

func (v *NullableEnvironment) Set(val *Environment) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableEnvironment(val *Environment) *NullableEnvironment {
	return &NullableEnvironment{value: val, isSet: true}
}

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

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