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

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

// LogService20210330TestDestinationResponse log service 20210330 test destination response
//
// swagger:model log_service_20210330TestDestinationResponse
type LogService20210330TestDestinationResponse struct {

	// error_message is an optional message that includes additional details about the error
	// it would be used if the error message is meaningful or actionable to the customer
	// in some cases (e.g. internal errors) we will not include any messages
	ErrorMessage string `json:"error_message,omitempty"`

	// request_id is a unique id that can be used to refer to this specific test operation
	RequestID string `json:"request_id,omitempty"`

	// status indicates whether the destination is successfully streaming logs to the provider or failing to do so.
	Status *LogService20210330DestinationStatus `json:"status,omitempty"`

	// test_payload is the log payload we sent to the customer destination
	// this would only be set if the status is "success"
	TestPayload string `json:"test_payload,omitempty"`
}

// Validate validates this log service 20210330 test destination response
func (m *LogService20210330TestDestinationResponse) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *LogService20210330TestDestinationResponse) validateStatus(formats strfmt.Registry) error {
	if swag.IsZero(m.Status) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this log service 20210330 test destination response based on the context it is used
func (m *LogService20210330TestDestinationResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *LogService20210330TestDestinationResponse) contextValidateStatus(ctx context.Context, formats strfmt.Registry) error {

	if m.Status != nil {

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

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

	return nil
}

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

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