logsapi/model/model_json.go (130 lines of code) (raw):
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Code generated by "generate-fastjson". DO NOT EDIT.
package model
import (
"go.elastic.co/fastjson"
)
func (v *LogContainer) MarshalFastJSON(w *fastjson.Writer) error {
var firstErr error
w.RawByte('{')
if v.Log != nil {
w.RawString("\"log\":")
if err := v.Log.MarshalFastJSON(w); err != nil && firstErr == nil {
firstErr = err
}
}
w.RawByte('}')
return firstErr
}
func (v *LogLine) MarshalFastJSON(w *fastjson.Writer) error {
var firstErr error
w.RawByte('{')
w.RawString("\"@timestamp\":")
if err := v.Timestamp.MarshalFastJSON(w); err != nil && firstErr == nil {
firstErr = err
}
w.RawString(",\"message\":")
w.String(v.Message)
if v.FAAS != nil {
w.RawString(",\"faas\":")
if err := v.FAAS.MarshalFastJSON(w); err != nil && firstErr == nil {
firstErr = err
}
}
w.RawByte('}')
return firstErr
}
func (v *FAAS) MarshalFastJSON(w *fastjson.Writer) error {
w.RawByte('{')
first := true
if v.Execution != "" {
const prefix = ",\"execution\":"
if first {
first = false
w.RawString(prefix[1:])
} else {
w.RawString(prefix)
}
w.String(v.Execution)
}
if v.ID != "" {
const prefix = ",\"id\":"
if first {
first = false
w.RawString(prefix[1:])
} else {
w.RawString(prefix)
}
w.String(v.ID)
}
w.RawByte('}')
return nil
}
func (v MetricsContainer) MarshalFastJSON(w *fastjson.Writer) error {
var firstErr error
w.RawByte('{')
if v.Metrics != nil {
w.RawString("\"metricset\":")
if err := v.Metrics.MarshalFastJSON(w); err != nil && firstErr == nil {
firstErr = err
}
}
w.RawByte('}')
return firstErr
}
func (v *Metrics) MarshalFastJSON(w *fastjson.Writer) error {
var firstErr error
w.RawByte('{')
w.RawString("\"timestamp\":")
if err := v.Timestamp.MarshalFastJSON(w); err != nil && firstErr == nil {
firstErr = err
}
if v.FAAS != nil {
w.RawString(",\"faas\":")
if err := v.FAAS.MarshalFastJSON(w); err != nil && firstErr == nil {
firstErr = err
}
}
if v.Samples != nil {
w.RawString(",\"samples\":")
w.RawByte('{')
{
first := true
for k, v := range v.Samples {
if first {
first = false
} else {
w.RawByte(',')
}
w.String(k)
w.RawByte(':')
if err := v.MarshalFastJSON(w); err != nil && firstErr == nil {
firstErr = err
}
}
}
w.RawByte('}')
}
w.RawByte('}')
return firstErr
}
func (v *ExtendedFAAS) MarshalFastJSON(w *fastjson.Writer) error {
w.RawByte('{')
w.RawString("\"coldstart\":")
w.Bool(v.Coldstart)
if v.Execution != "" {
w.RawString(",\"execution\":")
w.String(v.Execution)
}
if v.ID != "" {
w.RawString(",\"id\":")
w.String(v.ID)
}
w.RawByte('}')
return nil
}
func (v *Metric) MarshalFastJSON(w *fastjson.Writer) error {
w.RawByte('{')
w.RawString("\"value\":")
w.Float64(v.Value)
w.RawByte('}')
return nil
}