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

// PredictionLogIngestionResourceRequest struct for PredictionLogIngestionResourceRequest
type PredictionLogIngestionResourceRequest struct {
	CpuRequest    *string `json:"cpu_request,omitempty"`
	MemoryRequest *string `json:"memory_request,omitempty"`
	Replica       int32   `json:"replica"`
}

type _PredictionLogIngestionResourceRequest PredictionLogIngestionResourceRequest

// NewPredictionLogIngestionResourceRequest instantiates a new PredictionLogIngestionResourceRequest 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 NewPredictionLogIngestionResourceRequest(replica int32) *PredictionLogIngestionResourceRequest {
	this := PredictionLogIngestionResourceRequest{}
	this.Replica = replica
	return &this
}

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

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

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

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

	return false
}

// SetCpuRequest gets a reference to the given string and assigns it to the CpuRequest field.
func (o *PredictionLogIngestionResourceRequest) SetCpuRequest(v string) {
	o.CpuRequest = &v
}

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

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

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

	return false
}

// SetMemoryRequest gets a reference to the given string and assigns it to the MemoryRequest field.
func (o *PredictionLogIngestionResourceRequest) SetMemoryRequest(v string) {
	o.MemoryRequest = &v
}

// GetReplica returns the Replica field value
func (o *PredictionLogIngestionResourceRequest) GetReplica() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Replica
}

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

// SetReplica sets field value
func (o *PredictionLogIngestionResourceRequest) SetReplica(v int32) {
	o.Replica = v
}

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

func (o PredictionLogIngestionResourceRequest) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.CpuRequest) {
		toSerialize["cpu_request"] = o.CpuRequest
	}
	if !IsNil(o.MemoryRequest) {
		toSerialize["memory_request"] = o.MemoryRequest
	}
	toSerialize["replica"] = o.Replica
	return toSerialize, nil
}

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

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

	varPredictionLogIngestionResourceRequest := _PredictionLogIngestionResourceRequest{}

	err = json.Unmarshal(bytes, &varPredictionLogIngestionResourceRequest)

	if err != nil {
		return err
	}

	*o = PredictionLogIngestionResourceRequest(varPredictionLogIngestionResourceRequest)

	return err
}

type NullablePredictionLogIngestionResourceRequest struct {
	value *PredictionLogIngestionResourceRequest
	isSet bool
}

func (v NullablePredictionLogIngestionResourceRequest) Get() *PredictionLogIngestionResourceRequest {
	return v.value
}

func (v *NullablePredictionLogIngestionResourceRequest) Set(val *PredictionLogIngestionResourceRequest) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullablePredictionLogIngestionResourceRequest(val *PredictionLogIngestionResourceRequest) *NullablePredictionLogIngestionResourceRequest {
	return &NullablePredictionLogIngestionResourceRequest{value: val, isSet: true}
}

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

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