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

// ApiKeyResponse struct for ApiKeyResponse
type ApiKeyResponse struct {
	// The name of the API key
	Name string `json:"name"`
	// The 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 expires
	ExpiresAt NullableTime `json:"expiresAt"`
	AdditionalProperties map[string]interface{}
}

type _ApiKeyResponse ApiKeyResponse

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

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

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

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

// GetValue returns the Value field value
func (o *ApiKeyResponse) 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 *ApiKeyResponse) GetValueOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Value, true
}

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

// GetCreatedAt returns the CreatedAt field value
func (o *ApiKeyResponse) 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 *ApiKeyResponse) GetCreatedAtOk() (*time.Time, bool) {
	if o == nil {
		return nil, false
	}
	return &o.CreatedAt, true
}

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

// GetPermissions returns the Permissions field value
func (o *ApiKeyResponse) 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 *ApiKeyResponse) GetPermissionsOk() ([]string, bool) {
	if o == nil {
		return nil, false
	}
	return o.Permissions, true
}

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

// GetExpiresAt returns the ExpiresAt field value
// If the value is explicit nil, the zero value for time.Time will be returned
func (o *ApiKeyResponse) 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 *ApiKeyResponse) GetExpiresAtOk() (*time.Time, bool) {
	if o == nil {
		return nil, false
	}
	return o.ExpiresAt.Get(), o.ExpiresAt.IsSet()
}

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

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

func (o ApiKeyResponse) 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["expiresAt"] = o.ExpiresAt.Get()

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

	return toSerialize, nil
}

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

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

	varApiKeyResponse := _ApiKeyResponse{}

	err = json.Unmarshal(data, &varApiKeyResponse)

	if err != nil {
		return err
	}

	*o = ApiKeyResponse(varApiKeyResponse)

	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, "expiresAt")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableApiKeyResponse struct {
	value *ApiKeyResponse
	isSet bool
}

func (v NullableApiKeyResponse) Get() *ApiKeyResponse {
	return v.value
}

func (v *NullableApiKeyResponse) Set(val *ApiKeyResponse) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableApiKeyResponse(val *ApiKeyResponse) *NullableApiKeyResponse {
	return &NullableApiKeyResponse{value: val, isSet: true}
}

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

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


