22
33namespace LKDev \HetznerCloud \Models \Zones ;
44
5- class RRSet
5+ use LKDev \HetznerCloud \Clients \GuzzleClient ;
6+ use LKDev \HetznerCloud \HetznerAPIClient ;
7+ use LKDev \HetznerCloud \Models \Contracts \Resource ;
8+ use LKDev \HetznerCloud \Models \Model ;
9+
10+ class RRSet extends Model implements Resource
611{
712 public string $ id ;
813 public string $ name ;
@@ -12,29 +17,38 @@ class RRSet
1217 public array $ labels ;
1318 public ?RRSetProtection $ protection ;
1419
20+ public int $ zone ;
21+
1522 /**
16- * @param string $id
17- * @param string $name
18- * @param string $type
19- * @param int $ttl
20- * @param array $records
21- * @param array|null $labels
22- * @param RRSetProtection|null $protection
23+ * @param string $id
24+ * @param GuzzleClient|null $client
2325 */
24- public function __construct (string $ id , string $ name , string $ type , int $ ttl , array $ records , ? array $ labels , ? RRSetProtection $ protection )
26+ public function __construct (string $ id , ? GuzzleClient $ client = null )
2527 {
2628 $ this ->id = $ id ;
27- $ this ->name = $ name ;
28- $ this ->type = $ type ;
29- $ this ->ttl = $ ttl ;
30- $ this ->records = $ records ;
31- $ this ->labels = $ labels ;
32- $ this ->protection = $ protection ;
29+
30+ parent ::__construct ($ client );
31+ }
32+
33+ /**
34+ * @param $data
35+ * @return \LKDev\HetznerCloud\Models\Zones\RRSet
36+ */
37+ public function setAdditionalData ($ data )
38+ {
39+ $ this ->name = $ data ->name ;
40+ $ this ->type = $ data ->type ;
41+ $ this ->ttl = $ data ->ttl ;
42+ $ this ->records = $ data ->records ;
43+ $ this ->labels = get_object_vars ($ data ->labels );
44+ $ this ->protection = RRSetProtection::parse ($ data ->protection );
45+ $ this ->zone = $ data ->zone ;
46+ return $ this ;
3347 }
3448
35- public static function fromResponse ( array $ data ): RRSet
49+ public static function parse ( $ input ): RRSet
3650 {
37- return new self ($ data [ ' id ' ], $ data [ ' name ' ], $ data [ ' type ' ], $ data [ ' ttl ' ], $ data [ ' records ' ], get_object_vars ( $ data [ ' labels ' ]), RRSetProtection:: parse ( $ data [ ' protection ' ]) );
51+ return ( new self ($ input -> id ))-> setAdditionalData ( $ input );
3852 }
3953
4054 public function __toRequest (): array
@@ -45,10 +59,50 @@ public function __toRequest(): array
4559 'ttl ' => $ this ->ttl ,
4660 'records ' => $ this ->records ,
4761 ];
48- if (! empty ($ this ->labels )) {
62+ if (!empty ($ this ->labels )) {
4963 $ r ['labels ' ] = $ this ->labels ;
5064 }
5165
5266 return $ r ;
5367 }
68+
69+ public function reload ()
70+ {
71+ return HetznerAPIClient::$ instance ->zones ()->getById ($ this ->zone )->getRRSet ($ this ->id );
72+ }
73+
74+ public function delete ()
75+ {
76+ // TODO: Implement delete() method.
77+ }
78+
79+ public function update (array $ data )
80+ {
81+ // TODO: Implement update() method.
82+ }
83+
84+ public function changeProtection (RRSetProtection $ protection )
85+ {
86+ // TODO: Implement changeProtection() method.
87+ }
88+
89+ public function changeTTL (int $ ttl )
90+ {
91+ // TODO: Implement changeTTL() method.
92+ }
93+
94+ public function setRecords (array $ records )
95+ {
96+ // TODO: Implement setRecords() method.
97+ }
98+
99+ public function addRecords (array $ records )
100+ {
101+ // TODO: Implement addRecords() method.
102+ }
103+
104+ public function removeRecords (array $ records )
105+ {
106+ // TODO: Implement removeRecords() method.
107+ }
54108}
0 commit comments