hnhdigital-os/php-linode-api

View on GitHub
src/endpoints/Image.php

Summary

Maintainability
A
3 hrs
Test Coverage
<?php

namespace HnhDigital\LinodeApi;

/*
 * This file is part of the PHP Linode API.
 *
 * (c) H&H|Digital <hello@hnh.digital>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

use HnhDigital\LinodeApi\Foundation\Base;

/**
 * This is the Image class.
 *
 * This file is automatically generated.
 *
 * @link https://developers.linode.com/api/v4#tag/Images
 *
 * @author Rocco Howard <rocco@hnh.digital>
 */
class Image extends Base
{
    /**
     * Endpoint.
     *
     * @var string
     */
    protected $endpoint = 'images/%s';

    /**
     * Image Id.
     *
     * @var string
     */
    protected $image_id;

    /**
     * This model is fillable.
     *
     * @var bool
     */
    protected $fillable = true;

    /**
     * This model's method that provides the data to fill it.
     *
     * @var string
     */
    protected $fill_method = 'get';

    /**
     * Constructor.
     *
     * @return void
     */
    public function __construct($image_id, $fill = [])
    {
        $this->image_id = $image_id;
        parent::__construct($image_id, $fill);
    }

    /**
     * Get information about a single Image.
     *
     * @link https://developers.linode.com/api/v4#operation/getImage
     *
     * @return array
     */
    public function get()
    {
        return $this->apiCall('get', '', [], ['auto-fill' => true]);
    }

    /**
     * Updates a private Image that you have permission to `read_write`.
     *
     * @param string $image_id ID of the Image to look up.
     *
     * @link https://developers.linode.com/api/v4#operation/updateImage
     *
     * @return void
     */
    public function update($optional = [])
    {
        return $this->apiCall('put', '', ['json' => $this->getDirty($optional)]);
    }

    /**
     * Deletes a private Image you have permission to `read_write`.
     *
     *
     * Deleting an Image is a destructive action and cannot be undone.
     *
     * @param string $image_id ID of the Image to look up.
     *
     * @link https://developers.linode.com/api/v4#operation/deleteImage
     *
     * @return void
     */
    public function delete()
    {
        return $this->apiCall('delete', '');
    }
}