Skip to content

Commit

Permalink
Merge branch '4.1' into 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Feb 1, 2021
2 parents 7f46455 + 1522832 commit c20a37f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ CHANGE LOG
* UPCOMING


## 4.1.1 (UPCOMING)

* Fixed incorrect floating IP IDs


## 4.1.0 (25/01/2021)

* Added app platform API support
Expand Down
48 changes: 24 additions & 24 deletions src/Api/FloatingIp.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ public function getAll()
}

/**
* @param int $id
* @param string $ipAddress
*
* @throws ExceptionInterface
*
* @return FloatingIpEntity
*/
public function getById(int $id)
public function getById(string $ipAddress)
{
$ip = $this->get(\sprintf('floating_ips/%s', $id));
$ip = $this->get(\sprintf('floating_ips/%s', $ipAddress));

return new FloatingIpEntity($ip->floating_ip);
}
Expand Down Expand Up @@ -80,84 +80,84 @@ public function createReserved(string $regionSlug)
}

/**
* @param int $id
* @param string $ipAddress
*
* @throws ExceptionInterface
*
* @return void
*/
public function remove(int $id): void
public function remove(string $ipAddress): void
{
$this->delete(\sprintf('floating_ips/%s', $id));
$this->delete(\sprintf('floating_ips/%s', $ipAddress));
}

/**
* @param int $id
* @param string $ipAddress
*
* @throws ExceptionInterface
*
* @return ActionEntity[]
*/
public function getActions(int $id)
public function getActions(string $ipAddress)
{
$actions = $this->get(\sprintf('floating_ips/%s/actions', $id));
$actions = $this->get(\sprintf('floating_ips/%s/actions', $ipAddress));

return \array_map(function ($action) {
return new ActionEntity($action);
}, $actions->actions);
}

/**
* @param int $id
* @param int $actionId
* @param string $ipAddress
* @param int $actionId
*
* @throws ExceptionInterface
*
* @return ActionEntity
*/
public function getActionById(int $id, int $actionId)
public function getActionById(string $ipAddress, int $actionId)
{
$action = $this->get(\sprintf('floating_ips/%s/actions/%d', $id, $actionId));
$action = $this->get(\sprintf('floating_ips/%s/actions/%d', $ipAddress, $actionId));

return new ActionEntity($action->action);
}

/**
* @param int $id
* @param int $dropletId
* @param string $ipAddress
* @param int $dropletId
*
* @throws ExceptionInterface
*
* @return ActionEntity
*/
public function assign(int $id, int $dropletId)
public function assign(string $ipAddress, int $dropletId)
{
return $this->executeAction($id, ['type' => 'assign', 'droplet_id' => $dropletId]);
return $this->executeAction($ipAddress, ['type' => 'assign', 'droplet_id' => $dropletId]);
}

/**
* @param int $id
* @param string $ipAddress
*
* @throws ExceptionInterface
*
* @return ActionEntity
*/
public function unassign(int $id)
public function unassign(string $ipAddress)
{
return $this->executeAction($id, ['type' => 'unassign']);
return $this->executeAction($ipAddress, ['type' => 'unassign']);
}

/**
* @param int $id
* @param array $options
* @param string $ipAddress
* @param array $options
*
* @throws ExceptionInterface
*
* @return ActionEntity
*/
private function executeAction(int $id, array $options)
private function executeAction(string $ipAddress, array $options)
{
$action = $this->post(\sprintf('floating_ips/%s/actions', $id), $options);
$action = $this->post(\sprintf('floating_ips/%s/actions', $ipAddress), $options);

return new ActionEntity($action->action);
}
Expand Down
2 changes: 1 addition & 1 deletion vendor-bin/phpstan/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"require": {
"php": "^7.2.5 || ^8.0",
"phpstan/phpstan": "0.12.69",
"phpstan/phpstan": "0.12.71",
"phpstan/phpstan-deprecation-rules": "0.12.6",
"phpstan/phpstan-strict-rules": "0.12.9",
"thecodingmachine/phpstan-strict-rules": "0.12.1",
Expand Down

0 comments on commit c20a37f

Please sign in to comment.