/*
Daytona

Daytona AI platform API Docs

API version: 1.0
Contact: support@daytona.com
*/

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

package apiclient

import (
	"encoding/json"
	"fmt"
)

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

// CreateSnapshot struct for CreateSnapshot
type CreateSnapshot struct {
	// The name of the snapshot
	Name string `json:"name"`
	// The image name of the snapshot
	ImageName *string `json:"imageName,omitempty"`
	// The entrypoint command for the snapshot
	Entrypoint []string `json:"entrypoint,omitempty"`
	// CPU cores allocated to the resulting sandbox
	Cpu *int32 `json:"cpu,omitempty"`
	// GPU units allocated to the resulting sandbox
	Gpu *int32 `json:"gpu,omitempty"`
	// Memory allocated to the resulting sandbox in GB
	Memory *int32 `json:"memory,omitempty"`
	// Disk space allocated to the sandbox in GB
	Disk *int32 `json:"disk,omitempty"`
	// Build information for the snapshot
	BuildInfo *CreateBuildInfo `json:"buildInfo,omitempty"`
	// ID of the region where the snapshot will be available. Defaults to organization default region if not specified.
	RegionId *string `json:"regionId,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _CreateSnapshot CreateSnapshot

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

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

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

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

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

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

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

	return false
}

// SetImageName gets a reference to the given string and assigns it to the ImageName field.
func (o *CreateSnapshot) SetImageName(v string) {
	o.ImageName = &v
}

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

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

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

	return false
}

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

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

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

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

	return false
}

// SetCpu gets a reference to the given int32 and assigns it to the Cpu field.
func (o *CreateSnapshot) SetCpu(v int32) {
	o.Cpu = &v
}

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

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

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

	return false
}

// SetGpu gets a reference to the given int32 and assigns it to the Gpu field.
func (o *CreateSnapshot) SetGpu(v int32) {
	o.Gpu = &v
}

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

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

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

	return false
}

// SetMemory gets a reference to the given int32 and assigns it to the Memory field.
func (o *CreateSnapshot) SetMemory(v int32) {
	o.Memory = &v
}

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

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

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

	return false
}

// SetDisk gets a reference to the given int32 and assigns it to the Disk field.
func (o *CreateSnapshot) SetDisk(v int32) {
	o.Disk = &v
}

// GetBuildInfo returns the BuildInfo field value if set, zero value otherwise.
func (o *CreateSnapshot) GetBuildInfo() CreateBuildInfo {
	if o == nil || IsNil(o.BuildInfo) {
		var ret CreateBuildInfo
		return ret
	}
	return *o.BuildInfo
}

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

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

	return false
}

// SetBuildInfo gets a reference to the given CreateBuildInfo and assigns it to the BuildInfo field.
func (o *CreateSnapshot) SetBuildInfo(v CreateBuildInfo) {
	o.BuildInfo = &v
}

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

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

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

	return false
}

// SetRegionId gets a reference to the given string and assigns it to the RegionId field.
func (o *CreateSnapshot) SetRegionId(v string) {
	o.RegionId = &v
}

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

func (o CreateSnapshot) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["name"] = o.Name
	if !IsNil(o.ImageName) {
		toSerialize["imageName"] = o.ImageName
	}
	if !IsNil(o.Entrypoint) {
		toSerialize["entrypoint"] = o.Entrypoint
	}
	if !IsNil(o.Cpu) {
		toSerialize["cpu"] = o.Cpu
	}
	if !IsNil(o.Gpu) {
		toSerialize["gpu"] = o.Gpu
	}
	if !IsNil(o.Memory) {
		toSerialize["memory"] = o.Memory
	}
	if !IsNil(o.Disk) {
		toSerialize["disk"] = o.Disk
	}
	if !IsNil(o.BuildInfo) {
		toSerialize["buildInfo"] = o.BuildInfo
	}
	if !IsNil(o.RegionId) {
		toSerialize["regionId"] = o.RegionId
	}

	for key, value := range o.AdditionalProperties {
		toSerialize[key] = value
	}

	return toSerialize, nil
}

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

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

	varCreateSnapshot := _CreateSnapshot{}

	err = json.Unmarshal(data, &varCreateSnapshot)

	if err != nil {
		return err
	}

	*o = CreateSnapshot(varCreateSnapshot)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "name")
		delete(additionalProperties, "imageName")
		delete(additionalProperties, "entrypoint")
		delete(additionalProperties, "cpu")
		delete(additionalProperties, "gpu")
		delete(additionalProperties, "memory")
		delete(additionalProperties, "disk")
		delete(additionalProperties, "buildInfo")
		delete(additionalProperties, "regionId")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableCreateSnapshot struct {
	value *CreateSnapshot
	isSet bool
}

func (v NullableCreateSnapshot) Get() *CreateSnapshot {
	return v.value
}

func (v *NullableCreateSnapshot) Set(val *CreateSnapshot) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableCreateSnapshot(val *CreateSnapshot) *NullableCreateSnapshot {
	return &NullableCreateSnapshot{value: val, isSet: true}
}

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

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


