// 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 (
	"encoding/json"

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

// ActionSendHTTP Send a HTTP message as an action
//
// swagger:model ActionSendHTTP
type ActionSendHTTP struct {

	// Text body to send over HTTP, can use templating
	Body string `json:"body,omitempty"`

	// file path (relative to OPENMOCK_TEMPLATES_DIR of OM) to load HTTP body from
	BodyFromFile string `json:"body_from_file,omitempty"`

	// map of string to string specifying HTTP headers to attach to our message
	Headers interface{} `json:"headers,omitempty"`

	// HTTP method to use for the send
	// Enum: [POST GET DELETE PUT OPTIONS HEAD]
	Method string `json:"method,omitempty"`

	// The URL to send HTTP to
	URL string `json:"url,omitempty"`
}

// Validate validates this action send HTTP
func (m *ActionSendHTTP) Validate(formats strfmt.Registry) error {
	var res []error

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

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

var actionSendHttpTypeMethodPropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["POST","GET","DELETE","PUT","OPTIONS","HEAD"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		actionSendHttpTypeMethodPropEnum = append(actionSendHttpTypeMethodPropEnum, v)
	}
}

const (

	// ActionSendHTTPMethodPOST captures enum value "POST"
	ActionSendHTTPMethodPOST string = "POST"

	// ActionSendHTTPMethodGET captures enum value "GET"
	ActionSendHTTPMethodGET string = "GET"

	// ActionSendHTTPMethodDELETE captures enum value "DELETE"
	ActionSendHTTPMethodDELETE string = "DELETE"

	// ActionSendHTTPMethodPUT captures enum value "PUT"
	ActionSendHTTPMethodPUT string = "PUT"

	// ActionSendHTTPMethodOPTIONS captures enum value "OPTIONS"
	ActionSendHTTPMethodOPTIONS string = "OPTIONS"

	// ActionSendHTTPMethodHEAD captures enum value "HEAD"
	ActionSendHTTPMethodHEAD string = "HEAD"
)

// prop value enum
func (m *ActionSendHTTP) validateMethodEnum(path, location string, value string) error {
	if err := validate.Enum(path, location, value, actionSendHttpTypeMethodPropEnum); err != nil {
		return err
	}
	return nil
}

func (m *ActionSendHTTP) validateMethod(formats strfmt.Registry) error {

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

	// value enum
	if err := m.validateMethodEnum("method", "body", m.Method); err != nil {
		return err
	}

	return nil
}

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

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