1<?php 2 3declare(strict_types = 1); 4 5namespace Elasticsearch\Endpoints\Snapshot; 6 7use Elasticsearch\Endpoints\AbstractEndpoint; 8use Elasticsearch\Common\Exceptions; 9 10/** 11 * Class Get 12 * 13 * @category Elasticsearch 14 * @package Elasticsearch\Endpoints\Snapshot 15 * @author Zachary Tong <zach@elastic.co> 16 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 17 * @link http://elastic.co 18 */ 19class Get extends AbstractEndpoint 20{ 21 /** 22 * A comma-separated list of repository names 23 * 24 * @var string 25 */ 26 private $repository; 27 28 /** 29 * A comma-separated list of snapshot names 30 * 31 * @var string 32 */ 33 private $snapshot; 34 35 public function setRepository(?string $repository): Get 36 { 37 if (isset($repository) !== true) { 38 return $this; 39 } 40 41 $this->repository = $repository; 42 43 return $this; 44 } 45 46 public function setSnapshot(?string $snapshot): Get 47 { 48 if (isset($snapshot) !== true) { 49 return $this; 50 } 51 52 $this->snapshot = $snapshot; 53 54 return $this; 55 } 56 57 /** 58 * @throws \Elasticsearch\Common\Exceptions\RuntimeException 59 */ 60 public function getURI(): string 61 { 62 if (isset($this->repository) !== true) { 63 throw new Exceptions\RuntimeException( 64 'repository is required for Get' 65 ); 66 } 67 if (isset($this->snapshot) !== true) { 68 throw new Exceptions\RuntimeException( 69 'snapshot is required for Get' 70 ); 71 } 72 return "/_snapshot/{$this->repository}/{$this->snapshot}"; 73 } 74 75 public function getParamWhitelist(): array 76 { 77 return [ 78 'master_timeout', 79 'ignore_unavailable', 80 'verbose' 81 ]; 82 } 83 84 public function getMethod(): string 85 { 86 return 'GET'; 87 } 88} 89