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

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

// LastOperationResource last operation resource
//
// swagger:model LastOperationResource
type LastOperationResource struct {

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

	// state
	// Required: true
	// Enum: [in progress succeeded failed]
	State *string `json:"state"`
}

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

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

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

var lastOperationResourceTypeStatePropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["in progress","succeeded","failed"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		lastOperationResourceTypeStatePropEnum = append(lastOperationResourceTypeStatePropEnum, v)
	}
}

const (

	// LastOperationResourceStateInProgress captures enum value "in progress"
	LastOperationResourceStateInProgress string = "in progress"

	// LastOperationResourceStateSucceeded captures enum value "succeeded"
	LastOperationResourceStateSucceeded string = "succeeded"

	// LastOperationResourceStateFailed captures enum value "failed"
	LastOperationResourceStateFailed string = "failed"
)

// prop value enum
func (m *LastOperationResource) validateStateEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, lastOperationResourceTypeStatePropEnum, true); err != nil {
		return err
	}
	return nil
}

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

	if err := validate.Required("state", "body", m.State); err != nil {
		return err
	}

	// value enum
	if err := m.validateStateEnum("state", "body", *m.State); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this last operation resource based on context it is used
func (m *LastOperationResource) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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