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

// PtyListResponse struct for PtyListResponse
type PtyListResponse struct {
	// List of active PTY sessions
	Sessions []PtySessionInfo `json:"sessions"`
	AdditionalProperties map[string]interface{}
}

type _PtyListResponse PtyListResponse

// NewPtyListResponse instantiates a new PtyListResponse 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 NewPtyListResponse(sessions []PtySessionInfo) *PtyListResponse {
	this := PtyListResponse{}
	this.Sessions = sessions
	return &this
}

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

// GetSessions returns the Sessions field value
func (o *PtyListResponse) GetSessions() []PtySessionInfo {
	if o == nil {
		var ret []PtySessionInfo
		return ret
	}

	return o.Sessions
}

// GetSessionsOk returns a tuple with the Sessions field value
// and a boolean to check if the value has been set.
func (o *PtyListResponse) GetSessionsOk() ([]PtySessionInfo, bool) {
	if o == nil {
		return nil, false
	}
	return o.Sessions, true
}

// SetSessions sets field value
func (o *PtyListResponse) SetSessions(v []PtySessionInfo) {
	o.Sessions = v
}

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

func (o PtyListResponse) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["sessions"] = o.Sessions

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

	return toSerialize, nil
}

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

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

	varPtyListResponse := _PtyListResponse{}

	err = json.Unmarshal(data, &varPtyListResponse)

	if err != nil {
		return err
	}

	*o = PtyListResponse(varPtyListResponse)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "sessions")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullablePtyListResponse struct {
	value *PtyListResponse
	isSet bool
}

func (v NullablePtyListResponse) Get() *PtyListResponse {
	return v.value
}

func (v *NullablePtyListResponse) Set(val *PtyListResponse) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullablePtyListResponse(val *PtyListResponse) *NullablePtyListResponse {
	return &NullablePtyListResponse{value: val, isSet: true}
}

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

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


