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

// OperationGetActionResp operation get action resp
//
// swagger:model operation.GetActionResp
type OperationGetActionResp struct {

	// action
	Action *OperationActionMetadata `json:"action,omitempty"`

	// errcode
	Errcode APIErrCode `json:"errcode,omitempty"`

	// errmsg
	Errmsg string `json:"errmsg,omitempty"`

	// trace id
	TraceID string `json:"trace_id,omitempty"`
}

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

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

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

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

func (m *OperationGetActionResp) validateAction(formats strfmt.Registry) error {
	if swag.IsZero(m.Action) { // not required
		return nil
	}

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

	return nil
}

func (m *OperationGetActionResp) validateErrcode(formats strfmt.Registry) error {
	if swag.IsZero(m.Errcode) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this operation get action resp based on the context it is used
func (m *OperationGetActionResp) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *OperationGetActionResp) contextValidateAction(ctx context.Context, formats strfmt.Registry) error {

	if m.Action != nil {

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

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

	return nil
}

func (m *OperationGetActionResp) contextValidateErrcode(ctx context.Context, formats strfmt.Registry) error {

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

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

	return nil
}

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

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