File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /** @noinspection ForgottenDebugOutputInspection */
4+
5+ include '../vendor/autoload.php ' ;
6+
7+ use Typesense \Client ;
8+
9+ try {
10+ $ client = new Client (
11+ [
12+ 'api_key ' => 'xyz ' ,
13+ 'nodes ' => [
14+ [
15+ 'host ' => 'localhost ' ,
16+ 'port ' => '8108 ' ,
17+ 'protocol ' => 'http ' ,
18+ ],
19+ ],
20+ 'connection_timeout_seconds ' => 2 ,
21+ ]
22+ );
23+ echo '<pre> ' ;
24+
25+ print_r ($ client ->debug ->retrieve ());
26+ print_r ($ client ->metrics ->retrieve ());
27+ print_r ($ client ->health ->retrieve ());
28+ } catch (Exception $ e ) {
29+ echo $ e ->getMessage ();
30+ }
Original file line number Diff line number Diff line change 44
55use GuzzleHttp \Exception \GuzzleException ;
66use Typesense \Exceptions \TypesenseClientError ;
7- use Typesense \Lib \Configuration ;
87
98/**
109 * Class Alias
Original file line number Diff line number Diff line change 44
55use GuzzleHttp \Exception \GuzzleException ;
66use Typesense \Exceptions \TypesenseClientError ;
7- use Typesense \Lib \Configuration ;
87
98/**
109 * Class Aliases
Original file line number Diff line number Diff line change @@ -35,6 +35,21 @@ class Client
3535 */
3636 public Keys $ keys ;
3737
38+ /**
39+ * @var Debug
40+ */
41+ public Debug $ debug ;
42+
43+ /**
44+ * @var Metrics
45+ */
46+ public Metrics $ metrics ;
47+
48+ /**
49+ * @var Health
50+ */
51+ public Health $ health ;
52+
3853 /**
3954 * @var ApiCall
4055 */
@@ -55,6 +70,9 @@ public function __construct(array $config)
5570 $ this ->collections = new Collections ($ this ->apiCall );
5671 $ this ->aliases = new Aliases ($ this ->apiCall );
5772 $ this ->keys = new Keys ($ this ->apiCall );
73+ $ this ->debug = new Debug ($ this ->apiCall );
74+ $ this ->metrics = new Metrics ($ this ->apiCall );
75+ $ this ->health = new Health ($ this ->apiCall );
5876 }
5977
6078 /**
@@ -80,4 +98,28 @@ public function getKeys(): Keys
8098 {
8199 return $ this ->keys ;
82100 }
101+
102+ /**
103+ * @return Debug
104+ */
105+ public function getDebug (): Debug
106+ {
107+ return $ this ->debug ;
108+ }
109+
110+ /**
111+ * @return Metrics
112+ */
113+ public function getMetrics (): Metrics
114+ {
115+ return $ this ->metrics ;
116+ }
117+
118+ /**
119+ * @return Health
120+ */
121+ public function getHealth (): Health
122+ {
123+ return $ this ->health ;
124+ }
83125}
Original file line number Diff line number Diff line change 44
55use GuzzleHttp \Exception \GuzzleException ;
66use Typesense \Exceptions \TypesenseClientError ;
7- use Typesense \Lib \Configuration ;
87
98/**
109 * Class Collection
Original file line number Diff line number Diff line change 44
55use GuzzleHttp \Exception \GuzzleException ;
66use Typesense \Exceptions \TypesenseClientError ;
7- use Typesense \Lib \Configuration ;
87
98/**
109 * Class Collections
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Typesense ;
4+
5+ use GuzzleHttp \Exception \GuzzleException ;
6+ use Typesense \Exceptions \TypesenseClientError ;
7+
8+ /**
9+ * Class Debug
10+ *
11+ * @package \Typesense
12+ * @date 10/12/20
13+ */
14+ class Debug
15+ {
16+ public const RESOURCE_PATH = '/debug ' ;
17+
18+ /**
19+ * @var ApiCall
20+ */
21+ private ApiCall $ apiCall ;
22+
23+ /**
24+ * Alias constructor.
25+ *
26+ * @param ApiCall $apiCall
27+ */
28+ public function __construct (ApiCall $ apiCall )
29+ {
30+ $ this ->apiCall = $ apiCall ;
31+ }
32+
33+ /**
34+ * @return array
35+ * @throws TypesenseClientError|GuzzleException
36+ */
37+ public function retrieve (): array
38+ {
39+ return $ this ->apiCall ->get (Debug::RESOURCE_PATH , []);
40+ }
41+ }
Original file line number Diff line number Diff line change 44
55use GuzzleHttp \Exception \GuzzleException ;
66use Typesense \Exceptions \TypesenseClientError ;
7- use Typesense \Lib \Configuration ;
87
98/**
109 * Class Document
Original file line number Diff line number Diff line change 44
55use GuzzleHttp \Exception \GuzzleException ;
66use Typesense \Exceptions \TypesenseClientError ;
7- use Typesense \Lib \Configuration ;
87
98/**
109 * Class Documents
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Typesense ;
4+
5+ use GuzzleHttp \Exception \GuzzleException ;
6+ use Typesense \Exceptions \TypesenseClientError ;
7+
8+ /**
9+ * Class Health
10+ *
11+ * @package \Typesense
12+ * @date 10/12/20
13+ */
14+ class Health
15+ {
16+ public const RESOURCE_PATH = '/health ' ;
17+
18+ /**
19+ * @var ApiCall
20+ */
21+ private ApiCall $ apiCall ;
22+
23+ /**
24+ * Alias constructor.
25+ *
26+ * @param ApiCall $apiCall
27+ */
28+ public function __construct (ApiCall $ apiCall )
29+ {
30+ $ this ->apiCall = $ apiCall ;
31+ }
32+
33+ /**
34+ * @return array
35+ * @throws TypesenseClientError|GuzzleException
36+ */
37+ public function retrieve (): array
38+ {
39+ return $ this ->apiCall ->get (Health::RESOURCE_PATH , []);
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments