diff --git a/spec/DigitalOceanV2/Api/VolumeSpec.php b/spec/DigitalOceanV2/Api/VolumeSpec.php index c2d2cb2e..87164a35 100644 --- a/spec/DigitalOceanV2/Api/VolumeSpec.php +++ b/spec/DigitalOceanV2/Api/VolumeSpec.php @@ -516,4 +516,52 @@ public function it_returns_the_action_entity_after_resizing($adapter) $action->shouldReturnAnInstanceOf('DigitalOceanV2\Entity\Action'); $action->region->shouldReturnAnInstanceOf('DigitalOceanV2\Entity\Region'); } + + public function it_returns_the_action_entity_when_retrieving_action($adapter) + { + $response = <<get('https://api.digitalocean.com/v2/volumes/506f78a4-e098-11e5-ad9f-000f53306ae1/actions/72531856') + ->willReturn($response); + + $action = $this->getActionById('506f78a4-e098-11e5-ad9f-000f53306ae1', 72531856); + $action->id->shouldEqual(72531856); + $action->shouldReturnAnInstanceOf('DigitalOceanV2\Entity\Action'); + $action->region->shouldReturnAnInstanceOf('DigitalOceanV2\Entity\Region'); + } } diff --git a/src/Api/Volume.php b/src/Api/Volume.php index 3d8e5bfd..4740ba5f 100644 --- a/src/Api/Volume.php +++ b/src/Api/Volume.php @@ -183,4 +183,19 @@ public function resize($id, $newSize, $regionSlug) return new ActionEntity($action->action); } + + /** + * @param string $id + * @param int $actionId + * + * @return ActionEntity + */ + public function getActionById($id, $actionId) + { + $action = $this->adapter->get(sprintf('%s/volumes/%s/actions/%d', $this->endpoint, $id, $actionId)); + + $action = json_decode($action); + + return new ActionEntity($action->action); + } }