Scalr\Api\Service\User\V1beta0\Controller\Images::modifyAction PHP Method

modifyAction() public method

Change image attributes. Only the name be can changed!
public modifyAction ( string $imageId ) : Scalr\Api\DataType\ResultEnvelope
$imageId string Unique identifier of the image (uuid)
return Scalr\Api\DataType\ResultEnvelope
    public function modifyAction($imageId)
    {
        $this->checkScopedPermissions('IMAGES', 'MANAGE');
        $object = $this->request->getJsonBody();
        $imageAdapter = $this->adapter('image');
        //Pre validates the request object
        $imageAdapter->validateObject($object, Request::METHOD_PATCH);
        if (isset($object->scope) && $object->scope !== $this->getScope()) {
            throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, "Invalid scope");
        }
        //We have to do additional check instead of $this->checkPermissions() because we don't allow to modify SCALR level Image here
        $image = $this->getImage($imageId, true);
        //Copies all alterable properties to fetched Role Entity
        $imageAdapter->copyAlterableProperties($object, $image);
        //Re-validates an Entity
        $imageAdapter->validateEntity($image);
        //Saves verified results
        $image->save();
        return $this->result($imageAdapter->toData($image));
    }