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

	// cloudwatch
	Cloudwatch *HashicorpCloudVault20201125CloudWatch `json:"cloudwatch,omitempty"`

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

	// elasticsearch
	Elasticsearch *HashicorpCloudVault20201125Elasticsearch `json:"elasticsearch,omitempty"`

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

	// http
	HTTP *HashicorpCloudVault20201125HTTP `json:"http,omitempty"`

	// newrelic
	Newrelic *HashicorpCloudVault20201125NewRelic `json:"newrelic,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.validateCloudwatch(formats); err != nil {
		res = append(res, err)
	}

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

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

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

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

	if err := m.validateNewrelic(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) validateCloudwatch(formats strfmt.Registry) error {
	if swag.IsZero(m.Cloudwatch) { // not required
		return nil
	}

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

	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) validateElasticsearch(formats strfmt.Registry) error {
	if swag.IsZero(m.Elasticsearch) { // not required
		return nil
	}

	if m.Elasticsearch != nil {
		if err := m.Elasticsearch.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("elasticsearch")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("elasticsearch")
			}
			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) validateHTTP(formats strfmt.Registry) error {
	if swag.IsZero(m.HTTP) { // not required
		return nil
	}

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

	return nil
}

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

	if m.Newrelic != nil {
		if err := m.Newrelic.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("newrelic")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("newrelic")
			}
			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.contextValidateCloudwatch(ctx, formats); err != nil {
		res = append(res, err)
	}

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

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

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

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

	if err := m.contextValidateNewrelic(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) contextValidateCloudwatch(ctx context.Context, formats strfmt.Registry) error {

	if m.Cloudwatch != nil {

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

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

	return nil
}

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

	if m.Datadog != nil {

		if swag.IsZero(m.Datadog) { // not required
			return 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) contextValidateElasticsearch(ctx context.Context, formats strfmt.Registry) error {

	if m.Elasticsearch != nil {

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

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

	return nil
}

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

	if m.Grafana != nil {

		if swag.IsZero(m.Grafana) { // not required
			return 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) contextValidateHTTP(ctx context.Context, formats strfmt.Registry) error {

	if m.HTTP != nil {

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

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

	return nil
}

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

	if m.Newrelic != nil {

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

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

	return nil
}

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

	if m.Splunk != nil {

		if swag.IsZero(m.Splunk) { // not required
			return 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
}
