// Code generated by go-swagger; DO NOT EDIT.

package models

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
)

// LogService20210330ServiceLogEvent log service 20210330 service log event
//
// swagger:model log_service_20210330ServiceLogEvent
type LogService20210330ServiceLogEvent struct {

	// event_type represents the type log entry this event represents.
	EventType *LogService20210330EventType `json:"event_type,omitempty"`

	// insert_id is an optional, unique, identifier for the log event.
	// Clients can assign this field a value or it will be assigned as part of
	// processing by the log service.
	InsertID string `json:"insert_id,omitempty"`

	// json payload
	JSONPayload interface{} `json:"json_payload,omitempty"`

	// log_name is the service/resource name the log belongs to.
	LogName string `json:"log_name,omitempty"`

	// metadata is an extra information service teams want to add to a customer payload
	Metadata interface{} `json:"metadata,omitempty"`

	// text payload
	TextPayload string `json:"text_payload,omitempty"`
}

// Validate validates this log service 20210330 service log event
func (m *LogService20210330ServiceLogEvent) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateEventType(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *LogService20210330ServiceLogEvent) validateEventType(formats strfmt.Registry) error {
	if swag.IsZero(m.EventType) { // not required
		return nil
	}

	if m.EventType != nil {
		if err := m.EventType.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("event_type")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("event_type")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this log service 20210330 service log event based on the context it is used
func (m *LogService20210330ServiceLogEvent) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := m.contextValidateEventType(ctx, formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *LogService20210330ServiceLogEvent) contextValidateEventType(ctx context.Context, formats strfmt.Registry) error {

	if m.EventType != nil {

		if swag.IsZero(m.EventType) { // not required
			return nil
		}

		if err := m.EventType.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("event_type")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("event_type")
			}
			return err
		}
	}

	return nil
}

// MarshalBinary interface implementation
func (m *LogService20210330ServiceLogEvent) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *LogService20210330ServiceLogEvent) UnmarshalBinary(b []byte) error {
	var res LogService20210330ServiceLogEvent
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
