<?php

namespace Symfony\Config;

require_once __DIR__.\DIRECTORY_SEPARATOR.'AkeneoElasticsearch'.\DIRECTORY_SEPARATOR.'IndexesConfig.php';

use Symfony\Component\Config\Loader\ParamConfigurator;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;

/**
 * This class is automatically generated to help in creating a config.
 */
class AkeneoElasticsearchConfig implements \Symfony\Component\Config\Builder\ConfigBuilderInterface
{
    private $hosts;
    private $maxChunkSize;
    private $maxExpectedIndexationLatencyInMilliseconds;
    private $maxNumberOfRetries;
    private $indexes;
    private $_usedProperties = [];

    /**
     * @param ParamConfigurator|list<mixed|ParamConfigurator> $value
     * @return $this
     */
    public function hosts($value): self
    {
        $this->_usedProperties['hosts'] = true;
        $this->hosts = $value;

        return $this;
    }

    /**
     * Determines the maximum size of an individual bulk request in characters
     * @default null
     * @param ParamConfigurator|int $value
     * @return $this
     */
    public function maxChunkSize($value): self
    {
        $this->_usedProperties['maxChunkSize'] = true;
        $this->maxChunkSize = $value;

        return $this;
    }

    /**
     * Latency between api call and document availability for search in milliseconds
     * @default 1000
     * @param ParamConfigurator|int $value
     * @return $this
     */
    public function maxExpectedIndexationLatencyInMilliseconds($value): self
    {
        $this->_usedProperties['maxExpectedIndexationLatencyInMilliseconds'] = true;
        $this->maxExpectedIndexationLatencyInMilliseconds = $value;

        return $this;
    }

    /**
     * Number of retries after Elasticsearch technical errors
     * @default 3
     * @param ParamConfigurator|int $value
     * @return $this
     */
    public function maxNumberOfRetries($value): self
    {
        $this->_usedProperties['maxNumberOfRetries'] = true;
        $this->maxNumberOfRetries = $value;

        return $this;
    }

    public function indexes(array $value = []): \Symfony\Config\AkeneoElasticsearch\IndexesConfig
    {
        $this->_usedProperties['indexes'] = true;

        return $this->indexes[] = new \Symfony\Config\AkeneoElasticsearch\IndexesConfig($value);
    }

    public function getExtensionAlias(): string
    {
        return 'akeneo_elasticsearch';
    }

    public function __construct(array $value = [])
    {
        if (array_key_exists('hosts', $value)) {
            $this->_usedProperties['hosts'] = true;
            $this->hosts = $value['hosts'];
            unset($value['hosts']);
        }

        if (array_key_exists('max_chunk_size', $value)) {
            $this->_usedProperties['maxChunkSize'] = true;
            $this->maxChunkSize = $value['max_chunk_size'];
            unset($value['max_chunk_size']);
        }

        if (array_key_exists('max_expected_indexation_latency_in_milliseconds', $value)) {
            $this->_usedProperties['maxExpectedIndexationLatencyInMilliseconds'] = true;
            $this->maxExpectedIndexationLatencyInMilliseconds = $value['max_expected_indexation_latency_in_milliseconds'];
            unset($value['max_expected_indexation_latency_in_milliseconds']);
        }

        if (array_key_exists('max_number_of_retries', $value)) {
            $this->_usedProperties['maxNumberOfRetries'] = true;
            $this->maxNumberOfRetries = $value['max_number_of_retries'];
            unset($value['max_number_of_retries']);
        }

        if (array_key_exists('indexes', $value)) {
            $this->_usedProperties['indexes'] = true;
            $this->indexes = array_map(function ($v) { return new \Symfony\Config\AkeneoElasticsearch\IndexesConfig($v); }, $value['indexes']);
            unset($value['indexes']);
        }

        if ([] !== $value) {
            throw new InvalidConfigurationException(sprintf('The following keys are not supported by "%s": ', __CLASS__).implode(', ', array_keys($value)));
        }
    }

    public function toArray(): array
    {
        $output = [];
        if (isset($this->_usedProperties['hosts'])) {
            $output['hosts'] = $this->hosts;
        }
        if (isset($this->_usedProperties['maxChunkSize'])) {
            $output['max_chunk_size'] = $this->maxChunkSize;
        }
        if (isset($this->_usedProperties['maxExpectedIndexationLatencyInMilliseconds'])) {
            $output['max_expected_indexation_latency_in_milliseconds'] = $this->maxExpectedIndexationLatencyInMilliseconds;
        }
        if (isset($this->_usedProperties['maxNumberOfRetries'])) {
            $output['max_number_of_retries'] = $this->maxNumberOfRetries;
        }
        if (isset($this->_usedProperties['indexes'])) {
            $output['indexes'] = array_map(function ($v) { return $v->toArray(); }, $this->indexes);
        }

        return $output;
    }

}
