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

package types

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

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

// EventsMessage EventsMessage represents the information an event contains, the message
// at least contains type, action and id. type specifies which object generates
// the event, like container, or a network, or a volume. the action specifies
// the action name, like create, or destroy. the id identifies the object that
// generates the event.
// The message also can contain the EventsActor that describes the extra
// attributes that describe the event.
//
// swagger:model EventsMessage
type EventsMessage struct {

	// action
	Action string `json:"action,omitempty"`

	// actor
	Actor *EventsActor `json:"actor,omitempty"`

	// from
	From string `json:"from,omitempty"`

	// id
	ID string `json:"id,omitempty"`

	// status
	Status string `json:"status,omitempty"`

	// time
	Time int64 `json:"time,omitempty"`

	// time nano
	TimeNano int64 `json:"timeNano,omitempty"`

	// type
	Type EventType `json:"type,omitempty"`
}

// Validate validates this events message
func (m *EventsMessage) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *EventsMessage) validateActor(formats strfmt.Registry) error {

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

	if m.Actor != nil {
		if err := m.Actor.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("actor")
			}
			return err
		}
	}

	return nil
}

func (m *EventsMessage) validateType(formats strfmt.Registry) error {

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

	if err := m.Type.Validate(formats); err != nil {
		if ve, ok := err.(*errors.Validation); ok {
			return ve.ValidateName("type")
		}
		return err
	}

	return nil
}

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

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