Skip to content

Commit

Permalink
Add optional target project paramater to copy instance
Browse files Browse the repository at this point in the history
  • Loading branch information
turtle0x1 committed May 8, 2021
1 parent 755d8b0 commit 4ea3160
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All Notable changes to `php-lxd` will be documented in this file.

Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

# [0.19.1]

## Added
- Optional target project parameter to copy instance

# [0.19.0]

## Added
Expand Down
14 changes: 11 additions & 3 deletions src/Endpoint/InstaceBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,23 @@ public function create($name, array $options, $wait = false, array $requestHeade
* @param bool $wait Wait for operation to finish
* @return object
*/
public function copy($name, $copyName, array $options = [], $wait = false)
{
public function copy(
$name,
$copyName,
array $options = [],
$wait = false,
string $targetProject = ""
) {
$opts = $this->getOptions($copyName, $options);

$currentProject = $this->client->getProject();

$opts['source']['type'] = 'copy';
$opts['source']['source'] = $name;
$opts['source']['project'] = $currentProject;

$config = [
"project"=>$this->client->getProject()
"project"=>!empty($targetProject) ? $targetProject : $currentProject
];

$response = $this->post($this->getEndpoint(), $opts, $config);
Expand Down

0 comments on commit 4ea3160

Please sign in to comment.