@@ -34,6 +34,33 @@ public function loadEntity($data)
34
34
);
35
35
}
36
36
37
+ /**
38
+ * Assigns an IP address with a NIC
39
+ * @param $id
40
+ * @param $ipAddressId
41
+ * @return bool
42
+ */
43
+ public function assignIpAddress ($ id , $ ipAddressId )
44
+ {
45
+ $ response = $ this ->post (
46
+ $ this ->collectionPath . '/ ' . $ id . '/ip-addresses ' ,
47
+ json_encode ([ 'ip_address_id ' => $ ipAddressId ])
48
+ );
49
+ return $ response ->getStatusCode () == 202 ;
50
+ }
51
+
52
+ /**
53
+ * Detaches an IP address from a NIC
54
+ * @param $id
55
+ * @param $ipAddressId
56
+ * @return bool
57
+ */
58
+ public function detachIpAddress ($ id , $ ipAddressId )
59
+ {
60
+ $ response = $ this ->delete ($ this ->collectionPath . '/ ' . $ id . '/ip-addresses/ ' . $ ipAddressId );
61
+ return $ response ->getStatusCode () == 202 ;
62
+ }
63
+
37
64
/**
38
65
* Get the IP address records associated with a NIC
39
66
* @param $id
@@ -51,13 +78,22 @@ public function getIpAddresses($id)
51
78
return [];
52
79
}
53
80
81
+ $ ipAddressClient = new IpAddressesClient ();
82
+ $ page ->serializeWith (function ($ item ) use ($ ipAddressClient ) {
83
+ return $ ipAddressClient ->loadEntity ($ item );
84
+ });
85
+
86
+
54
87
$ items = $ page ->getItems ();
55
88
if ($ page ->totalPages () == 1 ) {
56
89
return $ items ;
57
90
}
58
91
59
92
while ($ page ->pageNumber () < $ page ->totalPages ()) {
60
93
$ page = $ this ->getPage ($ page ->pageNumber () + 1 , $ perPage );
94
+ $ page ->serializeWith (function ($ item ) use ($ ipAddressClient ) {
95
+ return $ ipAddressClient ->loadEntity ($ item );
96
+ });
61
97
$ items = array_merge (
62
98
$ items ,
63
99
$ page ->getItems ()
0 commit comments