<?php

namespace wpsolr\core\classes\hosting_api;

use wpsolr\core\classes\engines\WPSOLR_AbstractEngineClient;

class WPSOLR_Hosting_Api_OpenSearch_Wpsolr extends WPSOLR_Hosting_Api_Wpsolr_Abstract {

	const HOSTING_API_ID = 'wpsolr_os';

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

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

	public function get_url() {
		return 'https://www.wpsolr.com/wpsolr-search-hosting/';
	}

	public function get_documentation_url() {
		return 'https://www.wpsolr.com/guide/configuration-step-by-step-schematic/configure-your-indexes/0-connect-your-indexes/create-an-opensearch-index/create-a-wpsolr-hosting-opensearch-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_OPENSEARCH_SHARDS => [
					self::FIELD_NAME_LABEL                 => 'Number of read/write shards<br>',
					self::FIELD_NAME_PLACEHOLDER           => 'Number of shards',
					self::FIELD_NAME_DEFAULT_VALUE         => '1',
					self::FIELD_NAME_FORMAT                => [
						self::FIELD_NAME_FORMAT_TYPE        => self::FIELD_NAME_FORMAT_TYPE_READONLY,
						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_FORMAT_IS_UPDATE_ONLY => true,
				]
			],
			[
				self::FIELD_NAME_FIELDS_INDEX_OPENSEARCH_REPLICAS => [
					self::FIELD_NAME_LABEL                 => 'Number of read replicas per shard<br>1 node may fail.',
					self::FIELD_NAME_PLACEHOLDER           => 'Number of replicas',
					self::FIELD_NAME_DEFAULT_VALUE         => '1',
					self::FIELD_NAME_FORMAT                => [
						self::FIELD_NAME_FORMAT_TYPE        => self::FIELD_NAME_FORMAT_TYPE_READONLY,
						self::FIELD_NAME_FORMAT_ERROR_LABEL => self::ERROR_LABEL_EMPTY,
					],
					self::FIELD_NAME_FORMAT_IS_CREATE_ONLY => true,
					self::FIELD_NAME_FORMAT_IS_UPDATE_ONLY => true,
				]
			],
		] );
	}

}