/*
gravity

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

API version: 0.28.1
*/

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

package api

import (
	"bytes"
	"encoding/json"
	"fmt"
	"time"
)

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

// ApiAPILogMessage struct for ApiAPILogMessage
type ApiAPILogMessage struct {
	Fields  map[string]interface{} `json:"fields"`
	Level   string                 `json:"level"`
	Logger  string                 `json:"logger"`
	Message string                 `json:"message"`
	Node    string                 `json:"node"`
	Time    time.Time              `json:"time"`
}

type _ApiAPILogMessage ApiAPILogMessage

// NewApiAPILogMessage instantiates a new ApiAPILogMessage 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 NewApiAPILogMessage(fields map[string]interface{}, level string, logger string, message string, node string, time time.Time) *ApiAPILogMessage {
	this := ApiAPILogMessage{}
	this.Fields = fields
	this.Level = level
	this.Logger = logger
	this.Message = message
	this.Node = node
	this.Time = time
	return &this
}

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

// GetFields returns the Fields field value
// If the value is explicit nil, the zero value for map[string]interface{} will be returned
func (o *ApiAPILogMessage) GetFields() map[string]interface{} {
	if o == nil {
		var ret map[string]interface{}
		return ret
	}

	return o.Fields
}

// GetFieldsOk returns a tuple with the Fields 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 *ApiAPILogMessage) GetFieldsOk() (map[string]interface{}, bool) {
	if o == nil || IsNil(o.Fields) {
		return map[string]interface{}{}, false
	}
	return o.Fields, true
}

// SetFields sets field value
func (o *ApiAPILogMessage) SetFields(v map[string]interface{}) {
	o.Fields = v
}

// GetLevel returns the Level field value
func (o *ApiAPILogMessage) GetLevel() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Level
}

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

// SetLevel sets field value
func (o *ApiAPILogMessage) SetLevel(v string) {
	o.Level = v
}

// GetLogger returns the Logger field value
func (o *ApiAPILogMessage) GetLogger() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Logger
}

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

// SetLogger sets field value
func (o *ApiAPILogMessage) SetLogger(v string) {
	o.Logger = v
}

// GetMessage returns the Message field value
func (o *ApiAPILogMessage) GetMessage() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Message
}

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

// SetMessage sets field value
func (o *ApiAPILogMessage) SetMessage(v string) {
	o.Message = v
}

// GetNode returns the Node field value
func (o *ApiAPILogMessage) GetNode() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Node
}

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

// SetNode sets field value
func (o *ApiAPILogMessage) SetNode(v string) {
	o.Node = v
}

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

	return o.Time
}

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

// SetTime sets field value
func (o *ApiAPILogMessage) SetTime(v time.Time) {
	o.Time = v
}

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

func (o ApiAPILogMessage) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if o.Fields != nil {
		toSerialize["fields"] = o.Fields
	}
	toSerialize["level"] = o.Level
	toSerialize["logger"] = o.Logger
	toSerialize["message"] = o.Message
	toSerialize["node"] = o.Node
	toSerialize["time"] = o.Time
	return toSerialize, nil
}

func (o *ApiAPILogMessage) 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{
		"fields",
		"level",
		"logger",
		"message",
		"node",
		"time",
	}

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

	varApiAPILogMessage := _ApiAPILogMessage{}

	decoder := json.NewDecoder(bytes.NewReader(data))
	decoder.DisallowUnknownFields()
	err = decoder.Decode(&varApiAPILogMessage)

	if err != nil {
		return err
	}

	*o = ApiAPILogMessage(varApiAPILogMessage)

	return err
}

type NullableApiAPILogMessage struct {
	value *ApiAPILogMessage
	isSet bool
}

func (v NullableApiAPILogMessage) Get() *ApiAPILogMessage {
	return v.value
}

func (v *NullableApiAPILogMessage) Set(val *ApiAPILogMessage) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableApiAPILogMessage(val *ApiAPILogMessage) *NullableApiAPILogMessage {
	return &NullableApiAPILogMessage{value: val, isSet: true}
}

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

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