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

package ops

// 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"
)

// EntityIncidentLogItem entity incident log item
//
// swagger:model entity.IncidentLogItem
type EntityIncidentLogItem struct {

	// Will be deprecated next release
	CreatedAt string `json:"created_at,omitempty"`

	// description
	Description string `json:"description,omitempty"`

	// event time
	EventTime string `json:"event_time,omitempty"`

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

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

	// incident id
	IncidentID int64 `json:"incident_id,omitempty"`

	// item type
	ItemType EntityLogItemType `json:"item_type,omitempty"`

	// milestone type
	MilestoneType string `json:"milestone_type,omitempty"`

	// postmortem url
	PostmortemURL string `json:"postmortem_url,omitempty"`

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

// Validate validates this entity incident log item
func (m *EntityIncidentLogItem) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *EntityIncidentLogItem) validateItemType(formats strfmt.Registry) error {
	if swag.IsZero(m.ItemType) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this entity incident log item based on the context it is used
func (m *EntityIncidentLogItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *EntityIncidentLogItem) contextValidateItemType(ctx context.Context, formats strfmt.Registry) error {

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

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

	return nil
}

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

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