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

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

// ApiKeyList struct for ApiKeyList
type ApiKeyList struct {
	// The name of the API key
	Name string `json:"name"`
	// The masked API key value
	Value string `json:"value"`
	// When the API key was created
	CreatedAt time.Time `json:"createdAt"`
	// The list of organization resource permissions assigned to the API key
	Permissions []string `json:"permissions"`
	// When the API key was last used
	LastUsedAt NullableTime `json:"lastUsedAt"`
	// When the API key expires
	ExpiresAt NullableTime `json:"expiresAt"`
	// The user ID of the user who created the API key
	UserId string `json:"userId"`
	AdditionalProperties map[string]interface{}
}

type _ApiKeyList ApiKeyList

// NewApiKeyList instantiates a new ApiKeyList 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 NewApiKeyList(name string, value string, createdAt time.Time, permissions []string, lastUsedAt NullableTime, expiresAt NullableTime, userId string) *ApiKeyList {
	this := ApiKeyList{}
	this.Name = name
	this.Value = value
	this.CreatedAt = createdAt
	this.Permissions = permissions
	this.LastUsedAt = lastUsedAt
	this.ExpiresAt = expiresAt
	this.UserId = userId
	return &this
}

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

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

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

// GetValue returns the Value field value
func (o *ApiKeyList) GetValue() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Value
}

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

// SetValue sets field value
func (o *ApiKeyList) SetValue(v string) {
	o.Value = v
}

// GetCreatedAt returns the CreatedAt field value
func (o *ApiKeyList) GetCreatedAt() time.Time {
	if o == nil {
		var ret time.Time
		return ret
	}

	return o.CreatedAt
}

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

// SetCreatedAt sets field value
func (o *ApiKeyList) SetCreatedAt(v time.Time) {
	o.CreatedAt = v
}

// GetPermissions returns the Permissions field value
func (o *ApiKeyList) GetPermissions() []string {
	if o == nil {
		var ret []string
		return ret
	}

	return o.Permissions
}

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

// SetPermissions sets field value
func (o *ApiKeyList) SetPermissions(v []string) {
	o.Permissions = v
}

// GetLastUsedAt returns the LastUsedAt field value
// If the value is explicit nil, the zero value for time.Time will be returned
func (o *ApiKeyList) GetLastUsedAt() time.Time {
	if o == nil || o.LastUsedAt.Get() == nil {
		var ret time.Time
		return ret
	}

	return *o.LastUsedAt.Get()
}

// GetLastUsedAtOk returns a tuple with the LastUsedAt field value
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *ApiKeyList) GetLastUsedAtOk() (*time.Time, bool) {
	if o == nil {
		return nil, false
	}
	return o.LastUsedAt.Get(), o.LastUsedAt.IsSet()
}

// SetLastUsedAt sets field value
func (o *ApiKeyList) SetLastUsedAt(v time.Time) {
	o.LastUsedAt.Set(&v)
}

// GetExpiresAt returns the ExpiresAt field value
// If the value is explicit nil, the zero value for time.Time will be returned
func (o *ApiKeyList) GetExpiresAt() time.Time {
	if o == nil || o.ExpiresAt.Get() == nil {
		var ret time.Time
		return ret
	}

	return *o.ExpiresAt.Get()
}

// GetExpiresAtOk returns a tuple with the ExpiresAt field value
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *ApiKeyList) GetExpiresAtOk() (*time.Time, bool) {
	if o == nil {
		return nil, false
	}
	return o.ExpiresAt.Get(), o.ExpiresAt.IsSet()
}

// SetExpiresAt sets field value
func (o *ApiKeyList) SetExpiresAt(v time.Time) {
	o.ExpiresAt.Set(&v)
}

// GetUserId returns the UserId field value
func (o *ApiKeyList) GetUserId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.UserId
}

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

// SetUserId sets field value
func (o *ApiKeyList) SetUserId(v string) {
	o.UserId = v
}

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

func (o ApiKeyList) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["name"] = o.Name
	toSerialize["value"] = o.Value
	toSerialize["createdAt"] = o.CreatedAt
	toSerialize["permissions"] = o.Permissions
	toSerialize["lastUsedAt"] = o.LastUsedAt.Get()
	toSerialize["expiresAt"] = o.ExpiresAt.Get()
	toSerialize["userId"] = o.UserId

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

	return toSerialize, nil
}

func (o *ApiKeyList) 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",
		"value",
		"createdAt",
		"permissions",
		"lastUsedAt",
		"expiresAt",
		"userId",
	}

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

	varApiKeyList := _ApiKeyList{}

	err = json.Unmarshal(data, &varApiKeyList)

	if err != nil {
		return err
	}

	*o = ApiKeyList(varApiKeyList)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "name")
		delete(additionalProperties, "value")
		delete(additionalProperties, "createdAt")
		delete(additionalProperties, "permissions")
		delete(additionalProperties, "lastUsedAt")
		delete(additionalProperties, "expiresAt")
		delete(additionalProperties, "userId")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableApiKeyList struct {
	value *ApiKeyList
	isSet bool
}

func (v NullableApiKeyList) Get() *ApiKeyList {
	return v.value
}

func (v *NullableApiKeyList) Set(val *ApiKeyList) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableApiKeyList(val *ApiKeyList) *NullableApiKeyList {
	return &NullableApiKeyList{value: val, isSet: true}
}

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

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


