1+ <?php
2+ /**
3+ * @since Dec 2023
4+ * @author Haydar KULEKCI <haydarkulekci@gmail.com>
5+ */
6+
7+ namespace Qdrant \Models \Request \ClusterUpdate ;
8+
9+ class CreateShardingKeyOperation implements Operation
10+ {
11+ protected string $ shardKey ;
12+ protected ?int $ shardsNumber = null ;
13+ protected ?int $ replicationFactor = null ;
14+ protected ?int $ placement = null ;
15+
16+ public function __construct (string $ shardKey )
17+ {
18+ $ this ->shardKey = $ shardKey ;
19+ }
20+
21+ public function getKey (): string
22+ {
23+ return 'create_sharding_key ' ;
24+ }
25+
26+ public function toArray (): array
27+ {
28+ return array_filter ([
29+ 'shard_key ' => $ this ->shardKey ,
30+ 'shards_number ' => $ this ->shardsNumber ,
31+ 'replication_factor ' => $ this ->replicationFactor ,
32+ 'placement ' => $ this ->placement ,
33+ ], static function ($ v ) { return $ v !== null ; });
34+ }
35+
36+ public function setShardsNumber (int $ shardsNumber ): CreateShardingKeyOperation
37+ {
38+ $ this ->shardsNumber = $ shardsNumber ;
39+
40+ return $ this ;
41+ }
42+
43+ public function setPlacement (int $ placement ): CreateShardingKeyOperation
44+ {
45+ $ this ->placement = $ placement ;
46+
47+ return $ this ;
48+ }
49+
50+ public function setReplicationFactor (int $ replicationFactor ): CreateShardingKeyOperation
51+ {
52+ $ this ->replicationFactor = $ replicationFactor ;
53+
54+ return $ this ;
55+ }
56+ }
0 commit comments