src/endpoints/Linode/Instances/Disk.php
<?php
namespace HnhDigital\LinodeApi\Linode\Instances;
/*
* 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 Disk class.
*
* This file is automatically generated.
*
* @link https://developers.linode.com/api/v4#tag/Linode-Instances-Disks
*
* @author Rocco Howard <rocco@hnh.digital>
*/
class Disk extends Base
{
/**
* Endpoint.
*
* @var string
*/
protected $endpoint = 'linode/instances/%s/disks/%s';
/**
* Linode Id.
*
* @var int
*/
protected $linode_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($linode_id, $fill = [])
{
$this->linode_id = $linode_id;
parent::__construct($linode_id, $fill);
}
/**
* View Disk information for a Disk associated with this Linode.
*
* @link https://developers.linode.com/api/v4#operation/getLinodeDisk
*
* @return array
*/
public function get($disk_id)
{
return $this->apiCall('get', '', [], ['auto-fill' => true]);
}
/**
* Updates a Disk that you have permission to `read_write`.
*
* @param int $linode_id ID of the Linode to look up.
* @param int $disk_id ID of the Disk to look up.
*
* @link https://developers.linode.com/api/v4#operation/updateDisk
*
* @return void
*/
public function update($disk_id, $optional = [])
{
return $this->apiCall('put', '', ['json' => $this->getDirty($optional)]);
}
/**
* Resets the password of a Disk you have permission to `read_write`.
*
* @param int $linode_id ID of the Linode to look up.
* @param int $disk_id ID of the Disk to look up.
*
* @link https://developers.linode.com/api/v4#operation/resetDiskPassword
*
* @return mixed
*/
public function resetDiskPassword($disk_id, $optional = [])
{
return $this->apiCall('post', '/password', ['json' => array_merge([
'linode_id' => $linode_id,
'disk_id' => $disk_id,
], $optional)]);
}
/**
* Resizes a Disk you have permission to `read_write`.
* The Linode this Disk is attached to must be shut down for resizing to take effect.
* If you are resizing the Disk to a smaller size, it cannot be made smaller than what is required by the total size of the
* files current on the Disk. The Disk must not be in use. If the Disk is in use, the request will succeed but the resize
* will ultimately fail.
*
* @param int $linode_id ID of the Linode to look up.
* @param int $disk_id ID of the Disk to look up.
*
* @link https://developers.linode.com/api/v4#operation/resizeDisk
*
* @return mixed
*/
public function resizeDisk($disk_id, $optional = [])
{
return $this->apiCall('post', '/resize', ['json' => array_merge([
'linode_id' => $linode_id,
'disk_id' => $disk_id,
], $optional)]);
}
/**
* Deletes a Disk you have permission to `read_write`.
*
* Deleting a Disk is a destructive action and cannot be undone.
*
* @param int $linode_id ID of the Linode to look up.
* @param int $disk_id ID of the Disk to look up.
*
* @link https://developers.linode.com/api/v4#operation/deleteDisk
*
* @return void
*/
public function delete()
{
return $this->apiCall('delete', '');
}
}