Scalr\Service\Aws\Ec2\V20150415\Ec2Api::copyImage PHP Метод

copyImage() публичный Метод

Initiates the copy of an AMI from the specified source region to the region in which the API call is executed
public copyImage ( string $srcRegion, string $srcImageId, string $name = null, string $description = null, string $clientToken = null, string $destRegion = null ) : string
$srcRegion string The ID of the AWS region that contains the AMI to be copied.
$srcImageId string The ID of the Amazon EC2 AMI to copy.
$name string optional The name of the new Amazon EC2 AMI.
$description string optional A description of the new EC2 AMI in the destination region.
$clientToken string optional Unique, case-sensitive identifier you provide to ensure idempotency of the request
$destRegion string optional The ID of the destination region.
Результат string Returns ID of the created image on success.
    public function copyImage($srcRegion, $srcImageId, $name = null, $description = null, $clientToken = null, $destRegion = null)
    {
        $result = null;
        $options = array('SourceRegion' => (string) $srcRegion, 'SourceImageId' => (string) $srcImageId);
        if ($description !== null) {
            $options['Description'] = (string) $description;
        }
        if ($name !== null) {
            $options['Name'] = (string) $name;
        }
        if ($name !== null) {
            $options['ClientToken'] = (string) $clientToken;
        }
        if ($destRegion !== null) {
            //It overrides region to copy
            $options['_host'] = $this->ec2->getUrl($destRegion);
            $options['_region'] = $destRegion;
        }
        $response = $this->client->call(ucfirst(__FUNCTION__), $options);
        if ($response->getError() === false) {
            $sxml = simplexml_load_string($response->getRawContent());
            $result = (string) $sxml->imageId;
        }
        return $result;
    }
Ec2Api