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

// HashicorpCloudVault20201125ObservabilityConfig ObservabilityConfig is the config for observability settings
//
// swagger:model hashicorp.cloud.vault_20201125.ObservabilityConfig
type HashicorpCloudVault20201125ObservabilityConfig struct {

	// datadog
	Datadog *HashicorpCloudVault20201125Datadog `json:"datadog,omitempty"`

	// grafana
	Grafana *HashicorpCloudVault20201125Grafana `json:"grafana,omitempty"`

	// splunk
	Splunk *HashicorpCloudVault20201125Splunk `json:"splunk,omitempty"`
}

// Validate validates this hashicorp cloud vault 20201125 observability config
func (m *HashicorpCloudVault20201125ObservabilityConfig) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *HashicorpCloudVault20201125ObservabilityConfig) validateDatadog(formats strfmt.Registry) error {
	if swag.IsZero(m.Datadog) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudVault20201125ObservabilityConfig) validateGrafana(formats strfmt.Registry) error {
	if swag.IsZero(m.Grafana) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudVault20201125ObservabilityConfig) validateSplunk(formats strfmt.Registry) error {
	if swag.IsZero(m.Splunk) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this hashicorp cloud vault 20201125 observability config based on the context it is used
func (m *HashicorpCloudVault20201125ObservabilityConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *HashicorpCloudVault20201125ObservabilityConfig) contextValidateDatadog(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

func (m *HashicorpCloudVault20201125ObservabilityConfig) contextValidateGrafana(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

func (m *HashicorpCloudVault20201125ObservabilityConfig) contextValidateSplunk(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

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

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