// 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 (
	strfmt "github.com/go-openapi/strfmt"

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

// Operation operation
// swagger:model Operation

type Operation struct {

	// acquired lock
	AcquiredLock bool `json:"acquiredLock,omitempty"`

	// messages
	Messages OperationMessages `json:"messages,omitempty"`

	// mta Id
	MtaID string `json:"mtaId,omitempty"`

	// namespace
	// Read Only: true
	Namespace string `json:"namespace,omitempty"`

	// parameters
	Parameters map[string]interface{} `json:"parameters,omitempty"`

	// process Id
	ProcessID string `json:"processId,omitempty"`

	// process type
	ProcessType string `json:"processType,omitempty"`

	// space Id
	SpaceID string `json:"spaceId,omitempty"`

	// started at
	StartedAt string `json:"startedAt,omitempty"`

	// state
	State State `json:"state,omitempty"`

	// error type
	ErrorType ErrorType `json:"errorType,omitempty"`

	// user
	User string `json:"user,omitempty"`
}

/* polymorph Operation acquiredLock false */

/* polymorph Operation messages false */

/* polymorph Operation mtaId false */

/* polymorph Operation parameters false */

/* polymorph Operation processId false */

/* polymorph Operation processType false */

/* polymorph Operation spaceId false */

/* polymorph Operation startedAt false */

/* polymorph Operation state false */

/* polymorph Operation errorType false */

/* polymorph Operation user false */

// Validate validates this operation
func (m *Operation) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *Operation) validateState(formats strfmt.Registry) error {

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

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

	return nil
}

func (m *Operation) validateErrorType(formats strfmt.Registry) error {
	if swag.IsZero(m.ErrorType) {
		return nil
	}

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

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

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