// Code generated by mdatagen. DO NOT EDIT.

package samplereceiver

import (
	"errors"
	"time"

	"go.opentelemetry.io/collector/cmd/mdatagen/internal/samplepkg"
	"go.opentelemetry.io/collector/cmd/mdatagen/internal/samplereceiver/internal/metadata"
	"go.opentelemetry.io/collector/component"
	"go.opentelemetry.io/collector/config/configopaque"
)

// Config defines the configuration for Sample Receiver component.
type Config struct {
	// MetricsBuilderConfig is a configuration for sample metrics builder.
	metadata.MetricsBuilderConfig `mapstructure:",squash"`
	// API token used to authenticate with the endpoint.
	APIToken configopaque.String `mapstructure:"api_token,omitempty"`
	// Component ID used to identify this receiver instance.
	ComponentID component.ID `mapstructure:"component_id,omitempty"`
	// The endpoint to scrape metrics from.
	Endpoint string `mapstructure:"endpoint"`
	// Extra HTTP headers to attach to each request.
	Headers configopaque.MapList `mapstructure:"headers,omitempty"`
	// Maximum number of results to return per scrape.
	MaxResults int64                  `mapstructure:"max_results"`
	SamplePkg  samplepkg.SampleConfig `mapstructure:"sample_pkg"`
	// Timeout for scraping metrics.
	Timeout time.Duration `mapstructure:"timeout"`
	// prevent unkeyed literal initialization
	_ struct{}
}

// Validate validates the Config fields.
func (c *Config) Validate() error {
	var err error

	if c.Endpoint == "" {
		err = errors.Join(err, errors.New("endpoint is required"))
	}

	return err
}

func createDefaultConfig() component.Config {
	return &Config{
		Endpoint:   "localhost:12345",
		MaxResults: 100,
		SamplePkg:  samplepkg.NewDefaultSampleConfig(),
		Timeout:    10 * time.Second,
	}
}
