1<?php 2 3declare(strict_types = 1); 4 5namespace Elasticsearch\Endpoints; 6 7use Elasticsearch\Common\Exceptions; 8 9/** 10 * Class Clearscroll 11 * 12 * @category Elasticsearch 13 * @package Elasticsearch\Endpoints 14 * @author Zachary Tong <zach@elastic.co> 15 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 16 * @link http://elastic.co 17 */ 18class ClearScroll extends AbstractEndpoint 19{ 20 /** 21 * A comma-separated list of scroll IDs to clear 22 * 23 * @var string 24 */ 25 private $scrollId; 26 27 public function setScrollId(?string $scrollId): ClearScroll 28 { 29 if (isset($scrollId) !== true) { 30 return $this; 31 } 32 33 $this->scrollId = $scrollId; 34 35 return $this; 36 } 37 38 public function getURI(): string 39 { 40 $scrollId = $this->scrollId ?? null; 41 if (isset($scrollId)) { 42 return "/_search/scroll/$scrollId"; 43 } 44 return "/_search/scroll"; 45 } 46 47 public function setBody($body): ClearScroll 48 { 49 if (isset($body) !== true) { 50 return $this; 51 } 52 53 $this->body = $body; 54 55 return $this; 56 } 57 58 public function getBody() 59 { 60 if (isset($this->body)) { 61 return $this->body; 62 } 63 if (is_array($this->scrollId)) { 64 return ['scroll_id' => $this->scrollId]; 65 } 66 return ['scroll_id' => [$this->scrollId]]; 67 } 68 69 public function getParamWhitelist(): array 70 { 71 return []; 72 } 73 74 public function getMethod(): string 75 { 76 return 'DELETE'; 77 } 78} 79