// Code generated by github.com/ecordell/optgen. DO NOT EDIT.
package testserver

import (
	types "github.com/authzed/spicedb/pkg/caveats/types"
	util "github.com/authzed/spicedb/pkg/cmd/util"
	defaults "github.com/creasty/defaults"
	helpers "github.com/ecordell/optgen/helpers"
)

type ConfigOption func(c *Config)

// NewConfigWithOptions creates a new Config with the passed in options set
func NewConfigWithOptions(opts ...ConfigOption) *Config {
	c := &Config{}
	for _, o := range opts {
		o(c)
	}
	return c
}

// NewConfigWithOptionsAndDefaults creates a new Config with the passed in options set starting from the defaults
func NewConfigWithOptionsAndDefaults(opts ...ConfigOption) *Config {
	c := &Config{}
	defaults.MustSet(c)
	for _, o := range opts {
		o(c)
	}
	return c
}

// ToOption returns a new ConfigOption that sets the values from the passed in Config
func (c *Config) ToOption() ConfigOption {
	return func(to *Config) {
		to.GRPCServer = c.GRPCServer
		to.ReadOnlyGRPCServer = c.ReadOnlyGRPCServer
		to.HTTPGateway = c.HTTPGateway
		to.ReadOnlyHTTPGateway = c.ReadOnlyHTTPGateway
		to.LoadConfigs = c.LoadConfigs
		to.MaximumUpdatesPerWrite = c.MaximumUpdatesPerWrite
		to.MaximumPreconditionCount = c.MaximumPreconditionCount
		to.MaxCaveatContextSize = c.MaxCaveatContextSize
		to.MaxRelationshipContextSize = c.MaxRelationshipContextSize
		to.MaxReadRelationshipsLimit = c.MaxReadRelationshipsLimit
		to.MaxDeleteRelationshipsLimit = c.MaxDeleteRelationshipsLimit
		to.MaxLookupResourcesLimit = c.MaxLookupResourcesLimit
		to.MaxBulkExportRelationshipsLimit = c.MaxBulkExportRelationshipsLimit
		to.CaveatTypeSet = c.CaveatTypeSet
	}
}

// DebugMap returns a map form of Config for debugging
func (c Config) DebugMap() map[string]any {
	debugMap := map[string]any{}
	debugMap["GRPCServer"] = helpers.DebugValue(c.GRPCServer, false)
	debugMap["ReadOnlyGRPCServer"] = helpers.DebugValue(c.ReadOnlyGRPCServer, false)
	debugMap["HTTPGateway"] = helpers.DebugValue(c.HTTPGateway, false)
	debugMap["ReadOnlyHTTPGateway"] = helpers.DebugValue(c.ReadOnlyHTTPGateway, false)
	debugMap["LoadConfigs"] = helpers.DebugValue(c.LoadConfigs, false)
	debugMap["MaximumUpdatesPerWrite"] = helpers.DebugValue(c.MaximumUpdatesPerWrite, false)
	debugMap["MaximumPreconditionCount"] = helpers.DebugValue(c.MaximumPreconditionCount, false)
	debugMap["MaxCaveatContextSize"] = helpers.DebugValue(c.MaxCaveatContextSize, false)
	debugMap["MaxRelationshipContextSize"] = helpers.DebugValue(c.MaxRelationshipContextSize, false)
	debugMap["MaxReadRelationshipsLimit"] = helpers.DebugValue(c.MaxReadRelationshipsLimit, false)
	debugMap["MaxDeleteRelationshipsLimit"] = helpers.DebugValue(c.MaxDeleteRelationshipsLimit, false)
	debugMap["MaxLookupResourcesLimit"] = helpers.DebugValue(c.MaxLookupResourcesLimit, false)
	debugMap["MaxBulkExportRelationshipsLimit"] = helpers.DebugValue(c.MaxBulkExportRelationshipsLimit, false)
	return debugMap
}

// ConfigWithOptions configures an existing Config with the passed in options set
func ConfigWithOptions(c *Config, opts ...ConfigOption) *Config {
	for _, o := range opts {
		o(c)
	}
	return c
}

// WithOptions configures the receiver Config with the passed in options set
func (c *Config) WithOptions(opts ...ConfigOption) *Config {
	for _, o := range opts {
		o(c)
	}
	return c
}

// WithGRPCServer returns an option that can set GRPCServer on a Config
func WithGRPCServer(gRPCServer util.GRPCServerConfig) ConfigOption {
	return func(c *Config) {
		c.GRPCServer = gRPCServer
	}
}

// WithReadOnlyGRPCServer returns an option that can set ReadOnlyGRPCServer on a Config
func WithReadOnlyGRPCServer(readOnlyGRPCServer util.GRPCServerConfig) ConfigOption {
	return func(c *Config) {
		c.ReadOnlyGRPCServer = readOnlyGRPCServer
	}
}

// WithHTTPGateway returns an option that can set HTTPGateway on a Config
func WithHTTPGateway(hTTPGateway util.HTTPServerConfig) ConfigOption {
	return func(c *Config) {
		c.HTTPGateway = hTTPGateway
	}
}

// WithReadOnlyHTTPGateway returns an option that can set ReadOnlyHTTPGateway on a Config
func WithReadOnlyHTTPGateway(readOnlyHTTPGateway util.HTTPServerConfig) ConfigOption {
	return func(c *Config) {
		c.ReadOnlyHTTPGateway = readOnlyHTTPGateway
	}
}

// WithLoadConfigs returns an option that can append LoadConfigss to Config.LoadConfigs
func WithLoadConfigs(loadConfigs string) ConfigOption {
	return func(c *Config) {
		c.LoadConfigs = append(c.LoadConfigs, loadConfigs)
	}
}

// SetLoadConfigs returns an option that can set LoadConfigs on a Config
func SetLoadConfigs(loadConfigs []string) ConfigOption {
	return func(c *Config) {
		c.LoadConfigs = loadConfigs
	}
}

// WithMaximumUpdatesPerWrite returns an option that can set MaximumUpdatesPerWrite on a Config
func WithMaximumUpdatesPerWrite(maximumUpdatesPerWrite uint16) ConfigOption {
	return func(c *Config) {
		c.MaximumUpdatesPerWrite = maximumUpdatesPerWrite
	}
}

// WithMaximumPreconditionCount returns an option that can set MaximumPreconditionCount on a Config
func WithMaximumPreconditionCount(maximumPreconditionCount uint16) ConfigOption {
	return func(c *Config) {
		c.MaximumPreconditionCount = maximumPreconditionCount
	}
}

// WithMaxCaveatContextSize returns an option that can set MaxCaveatContextSize on a Config
func WithMaxCaveatContextSize(maxCaveatContextSize int) ConfigOption {
	return func(c *Config) {
		c.MaxCaveatContextSize = maxCaveatContextSize
	}
}

// WithMaxRelationshipContextSize returns an option that can set MaxRelationshipContextSize on a Config
func WithMaxRelationshipContextSize(maxRelationshipContextSize int) ConfigOption {
	return func(c *Config) {
		c.MaxRelationshipContextSize = maxRelationshipContextSize
	}
}

// WithMaxReadRelationshipsLimit returns an option that can set MaxReadRelationshipsLimit on a Config
func WithMaxReadRelationshipsLimit(maxReadRelationshipsLimit uint32) ConfigOption {
	return func(c *Config) {
		c.MaxReadRelationshipsLimit = maxReadRelationshipsLimit
	}
}

// WithMaxDeleteRelationshipsLimit returns an option that can set MaxDeleteRelationshipsLimit on a Config
func WithMaxDeleteRelationshipsLimit(maxDeleteRelationshipsLimit uint32) ConfigOption {
	return func(c *Config) {
		c.MaxDeleteRelationshipsLimit = maxDeleteRelationshipsLimit
	}
}

// WithMaxLookupResourcesLimit returns an option that can set MaxLookupResourcesLimit on a Config
func WithMaxLookupResourcesLimit(maxLookupResourcesLimit uint32) ConfigOption {
	return func(c *Config) {
		c.MaxLookupResourcesLimit = maxLookupResourcesLimit
	}
}

// WithMaxBulkExportRelationshipsLimit returns an option that can set MaxBulkExportRelationshipsLimit on a Config
func WithMaxBulkExportRelationshipsLimit(maxBulkExportRelationshipsLimit uint32) ConfigOption {
	return func(c *Config) {
		c.MaxBulkExportRelationshipsLimit = maxBulkExportRelationshipsLimit
	}
}

// WithCaveatTypeSet returns an option that can set CaveatTypeSet on a Config
func WithCaveatTypeSet(caveatTypeSet *types.TypeSet) ConfigOption {
	return func(c *Config) {
		c.CaveatTypeSet = caveatTypeSet
	}
}
