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

// LogService20210330StreamingFilter log service 20210330 streaming filter
//
// swagger:model log_service_20210330StreamingFilter
type LogService20210330StreamingFilter struct {

	// organization filter
	OrganizationFilter *LogService20210330StreamingOrganizationFilter `json:"organization_filter,omitempty"`

	// resource filter
	ResourceFilter *LogService20210330StreamingResourceFilter `json:"resource_filter,omitempty"`
}

// Validate validates this log service 20210330 streaming filter
func (m *LogService20210330StreamingFilter) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *LogService20210330StreamingFilter) validateOrganizationFilter(formats strfmt.Registry) error {
	if swag.IsZero(m.OrganizationFilter) { // not required
		return nil
	}

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

	return nil
}

func (m *LogService20210330StreamingFilter) validateResourceFilter(formats strfmt.Registry) error {
	if swag.IsZero(m.ResourceFilter) { // not required
		return nil
	}

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

	return nil
}

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

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

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

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

func (m *LogService20210330StreamingFilter) contextValidateOrganizationFilter(ctx context.Context, formats strfmt.Registry) error {

	if m.OrganizationFilter != nil {

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

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

	return nil
}

func (m *LogService20210330StreamingFilter) contextValidateResourceFilter(ctx context.Context, formats strfmt.Registry) error {

	if m.ResourceFilter != nil {

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

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

	return nil
}

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

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