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

// LogService20210330CreateStreamingDestinationFilterRequest CreateStreamingDestinationFilterRequest represents a reqeust to add a filter to a destination record.
// We don't require the project ID because we will pull it from the destination record.
//
// swagger:model log_service_20210330CreateStreamingDestinationFilterRequest
type LogService20210330CreateStreamingDestinationFilterRequest struct {

	// audit_filter represents a data plane audit filter.
	DataplaneAuditFilter *LogService20210330DataPlaneAuditFilter `json:"dataplane_audit_filter,omitempty"`

	// destination_id is represents the ID of destination we want to create the filter for.
	DestinationID string `json:"destination_id,omitempty"`

	// organization_filter represents an org level filter.
	OrganizationFilter *LogService20210330OrganizationFilter `json:"organization_filter,omitempty"`

	// organization id
	OrganizationID string `json:"organization_id,omitempty"`
}

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

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

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

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

func (m *LogService20210330CreateStreamingDestinationFilterRequest) validateDataplaneAuditFilter(formats strfmt.Registry) error {
	if swag.IsZero(m.DataplaneAuditFilter) { // not required
		return nil
	}

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

	return nil
}

func (m *LogService20210330CreateStreamingDestinationFilterRequest) 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
}

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

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

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

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

func (m *LogService20210330CreateStreamingDestinationFilterRequest) contextValidateDataplaneAuditFilter(ctx context.Context, formats strfmt.Registry) error {

	if m.DataplaneAuditFilter != nil {

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

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

	return nil
}

func (m *LogService20210330CreateStreamingDestinationFilterRequest) 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
}

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

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