Skip to content

Commit 4ea3160

Browse files
committed
Add optional target project paramater to copy instance
1 parent 755d8b0 commit 4ea3160

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All Notable changes to `php-lxd` will be documented in this file.
44

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

7+
# [0.19.1]
8+
9+
## Added
10+
- Optional target project parameter to copy instance
11+
712
# [0.19.0]
813

914
## Added

src/Endpoint/InstaceBase.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,23 @@ public function create($name, array $options, $wait = false, array $requestHeade
318318
* @param bool $wait Wait for operation to finish
319319
* @return object
320320
*/
321-
public function copy($name, $copyName, array $options = [], $wait = false)
322-
{
321+
public function copy(
322+
$name,
323+
$copyName,
324+
array $options = [],
325+
$wait = false,
326+
string $targetProject = ""
327+
) {
323328
$opts = $this->getOptions($copyName, $options);
324329

330+
$currentProject = $this->client->getProject();
331+
325332
$opts['source']['type'] = 'copy';
326333
$opts['source']['source'] = $name;
334+
$opts['source']['project'] = $currentProject;
327335

328336
$config = [
329-
"project"=>$this->client->getProject()
337+
"project"=>!empty($targetProject) ? $targetProject : $currentProject
330338
];
331339

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

0 commit comments

Comments
 (0)