Skip to content

Commit

Permalink
Merge pull request #43 from clue-labs/rename
Browse files Browse the repository at this point in the history
Add containerRename() API endpoint
  • Loading branch information
clue committed May 3, 2016
2 parents 8a802e0 + 9620a88 commit f356761
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,29 @@ public function containerKill($container, $signal = null)
)->then(array($this->parser, 'expectEmpty'));
}

/**
* Rename the container id
*
* Requires API v1.17+ / Docker v1.5+
*
* @param string $container container ID
* @param string $name new name for the container
* @return PromiseInterface Promise<null>
* @link https://docs.docker.com/engine/reference/api/docker_remote_api_v1.17/#rename-a-container
*/
public function containerRename($container, $name)
{
return $this->browser->post(
$this->uri->expand(
'/containers/{container}/rename{?name}',
array(
'container' => $container,
'name' => $name
)
)
)->then(array($this->parser, 'expectEmpty'));
}

/**
* Pause the container id
*
Expand Down
7 changes: 7 additions & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ public function testContainerRestartTimeout()
$this->expectPromiseResolveWith('', $this->client->containerRestart(123, 10));
}

public function testContainerRename()
{
$this->expectRequestFlow('POST', '/containers/123/rename?name=newname', $this->createResponse(), 'expectEmpty');

$this->expectPromiseResolveWith('', $this->client->containerRename(123, 'newname'));
}

public function testContainerPause()
{
$this->expectRequestFlow('post', '/containers/123/pause', $this->createResponse(), 'expectEmpty');
Expand Down

0 comments on commit f356761

Please sign in to comment.