<?php

namespace wpsolr\core\classes\hosting_api;

use wpsolr\core\classes\engines\WPSOLR_AbstractEngineClient;

class WPSOLR_Hosting_Api_Elasticsearch_Wpsolr extends WPSOLR_Hosting_Api_Wpsolr_Abstract {

	const HOSTING_API_ID = 'wpsolr_elasticsearch';

	static public function get_is_disabled(): bool {
		return true;
	}

	public function get_search_engine() {
		return WPSOLR_AbstractEngineClient::ENGINE_ELASTICSEARCH;
	}

	public function get_url() {
		return 'https://aiven.io/opensearch';
	}

	public function get_documentation_url() {
		return 'https://www.wpsolr.com/guide/configuration-step-by-step-schematic/configure-your-indexes/create-an-aiven-elasticsearch-index/';
	}

	public function get_is_endpoint_only() {
		return true;
	}

	public function get_ui_fields_child() {

		return array_merge( parent::get_ui_fields_child(), [
			[
				self::FIELD_NAME_FIELDS_INDEX_ELASTICSEARCH_SHARDS => [
					self::FIELD_NAME_LABEL                 => 'Number of read/write shards<br>We recommend 3 (one on each node). Minimum one will be created.',
					self::FIELD_NAME_PLACEHOLDER           => 'Number of shards',
					self::FIELD_NAME_DEFAULT_VALUE         => '3',
					self::FIELD_NAME_FORMAT                => [
						self::FIELD_NAME_FORMAT_TYPE        => self::FIELD_NAME_FORMAT_TYPE_INTEGER_MINIMUM_POSITIVE,
						self::FIELD_NAME_FORMAT_ERROR_LABEL => self::PLEASE_ENTER . 'a number of shards > 0',
					],
					self::FIELD_NAME_FORMAT_IS_CREATE_ONLY => true,
				]
			],
			[
				self::FIELD_NAME_FIELDS_INDEX_ELASTICSEARCH_REPLICAS => [
					self::FIELD_NAME_LABEL                 => 'Number of read replicas per shard<br>We recommend 2 (2 out of 3 nodes may fail). Minimum one will be created.',
					self::FIELD_NAME_PLACEHOLDER           => 'Number of replicas',
					self::FIELD_NAME_DEFAULT_VALUE         => '2',
					self::FIELD_NAME_FORMAT                => [
						self::FIELD_NAME_FORMAT_TYPE        => self::FIELD_NAME_FORMAT_TYPE_MANDATORY,
						self::FIELD_NAME_FORMAT_ERROR_LABEL => self::ERROR_LABEL_EMPTY,
					],
					self::FIELD_NAME_FORMAT_IS_CREATE_ONLY => true,
				]
			],
		] );
	}

}