Skip to content

Commit df7123e

Browse files
committed
Remove floating ip
1 parent 24fee16 commit df7123e

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

src/Compute/v2/Api.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,19 @@ public function getRDPConsole(): array
435435
];
436436
}
437437

438+
public function removeFloatingIp(): array
439+
{
440+
return [
441+
'method' => 'POST',
442+
'path' => 'servers/{id}/action',
443+
'jsonKey' => 'removeFloatingIp',
444+
'params' => [
445+
'id' => $this->params->urlId('server'),
446+
'address' => $this->params->ipAddress()
447+
]
448+
];
449+
}
450+
438451
public function getAddresses(): array
439452
{
440453
return [

src/Compute/v2/Models/Server.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,4 +459,9 @@ public function detachVolume(string $attachmentId)
459459
{
460460
$this->execute($this->api->deleteVolumeAttachments(), ['id' => $this->id, 'attachmentId' => $attachmentId]);
461461
}
462+
463+
public function removeFloatingIp(string $ipAddress)
464+
{
465+
$this->execute($this->api->removeFloatingIp(), ['id' => $this->id, 'address' => $ipAddress]);
466+
}
462467
}

src/Compute/v2/Params.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ public function ipv6(): array
110110
];
111111
}
112112

113+
public function ipAddress(): array
114+
{
115+
return [
116+
'type' => self::STRING_TYPE,
117+
'location' => self::JSON,
118+
'description' => 'The floating IP address',
119+
];
120+
}
121+
113122
public function imageId(): array
114123
{
115124
return [

tests/unit/Compute/v2/Models/ServerTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ public function test_it_reboots()
9595
$this->assertNull($this->server->reboot());
9696
}
9797

98+
public function test_it_removes_floating_ip()
99+
{
100+
$expectedJson = ['removeFloatingIp' => ['address' => '1.2.3.4']];
101+
102+
$this->setupMock('POST', 'servers/serverId/action', $expectedJson, [], new Response(202));
103+
104+
$this->assertNull($this->server->removeFloatingIp('1.2.3.4'));
105+
}
106+
98107
/**
99108
* @expectedException \RuntimeException
100109
*/

0 commit comments

Comments
 (0)