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

// HashicorpCloudConsulTelemetry20230414AgentTelemetryConfigResponse hashicorp cloud consul telemetry 20230414 agent telemetry config response
//
// swagger:model hashicorp.cloud.consul_telemetry_20230414.AgentTelemetryConfigResponse
type HashicorpCloudConsulTelemetry20230414AgentTelemetryConfigResponse struct {

	// refresh config
	RefreshConfig *HashicorpCloudConsulTelemetry20230414RefreshConfig `json:"refresh_config,omitempty"`

	// telemetry config
	TelemetryConfig *HashicorpCloudConsulTelemetry20230414TelemetryConfig `json:"telemetry_config,omitempty"`
}

// Validate validates this hashicorp cloud consul telemetry 20230414 agent telemetry config response
func (m *HashicorpCloudConsulTelemetry20230414AgentTelemetryConfigResponse) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudConsulTelemetry20230414AgentTelemetryConfigResponse) validateRefreshConfig(formats strfmt.Registry) error {
	if swag.IsZero(m.RefreshConfig) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudConsulTelemetry20230414AgentTelemetryConfigResponse) validateTelemetryConfig(formats strfmt.Registry) error {
	if swag.IsZero(m.TelemetryConfig) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this hashicorp cloud consul telemetry 20230414 agent telemetry config response based on the context it is used
func (m *HashicorpCloudConsulTelemetry20230414AgentTelemetryConfigResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudConsulTelemetry20230414AgentTelemetryConfigResponse) contextValidateRefreshConfig(ctx context.Context, formats strfmt.Registry) error {

	if m.RefreshConfig != nil {

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

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

	return nil
}

func (m *HashicorpCloudConsulTelemetry20230414AgentTelemetryConfigResponse) contextValidateTelemetryConfig(ctx context.Context, formats strfmt.Registry) error {

	if m.TelemetryConfig != nil {

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

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

	return nil
}

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

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