// Code generated by mdatagen. DO NOT EDIT.

package samplescraper

import (
	"errors"
	"time"

	"go.opentelemetry.io/collector/config/confighttp"
	"go.opentelemetry.io/collector/config/configoptional"
	"go.opentelemetry.io/collector/scraper/scraperhelper"
)

type TargetsItem struct {
	HTTPClient *confighttp.ClientConfig               `mapstructure:"http_client"`
	Interval   configoptional.Optional[time.Duration] `mapstructure:"interval"`
	Options    map[string]string                      `mapstructure:"options"`
}

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

	if c.HTTPClient == nil {
		err = errors.Join(err, errors.New("http_client is required"))
	}

	if inner_err := validateHTTPClient(c.HTTPClient); inner_err != nil {
		err = errors.Join(err, inner_err)
	}
	if c.Options == nil || len(c.Options) == 0 {
		err = errors.Join(err, errors.New("options is required"))
	}

	return err
}

// Configuration for the Sample Scraper.
type Config struct {
	scraperhelper.ControllerConfig `mapstructure:",squash"`
	// Targets configuration for the scraper.
	Targets *[]TargetsItem `mapstructure:"targets"`
}

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

	if c.Targets == nil || len(*c.Targets) == 0 {
		err = errors.Join(err, errors.New("targets is required"))
	}

	return err
}
