src/endpoints/Linode/Instances.php
<?php
namespace HnhDigital\LinodeApi\Linode;
/*
* 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 Instances class.
*
* This file is automatically generated.
*
* @link https://developers.linode.com/api/v4#tag/Linode-Instances
*
* @author Rocco Howard <rocco@hnh.digital>
*/
class Instances extends Base
{
/**
* Endpoint.
*
* @var string
*/
protected $endpoint = 'linode/instances';
/**
* Constructor.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Returns a paginated list of Linodes you have permission to view.
*
* @link https://developers.linode.com/api/v4#operation/getLinodeInstances
*
* @return array
*/
public function get()
{
return $this->apiSearch($this->endpoint, ['class' => 'Linode\Instance', 'parameters' => ['id']]);
}
/**
* Creates a Linode Instance on your Account. In order for this
* request to complete successfully, your User must have the `add_linodes` grant. Creating a
* new Linode will incur a charge on your Account.
*
* Linodes can be created using one of the available Types. See
* [GET /linode/types](/#operation/getLinodeTypes) to get more
* information about each Type's specs and cost.
*
* Linodes can be created in any one of our available
* [Regions](/#operation/getRegions) for a list
* of available Regions you can deploy your Linode in.
*
* Linodes can be created in a number of ways:.
*
* - Using a Linode Linux Distribution image or an Image you created based on another Linode.
* - The Linode will be `running` after it completes `provisioning`.
* - A default config with two Disks, one being a 512 swap disk, is created.
* - `swap_size` can be used to customize the swap disk size.
* - Requires a `root_pass` be supplied to use for the root User's Account.
* - It is recommended to supply SSH keys for the root User using the `authorized_keys` field.
*
* - Using a StackScript.
* - See [/linode/stackscripts](/#operation/getStackScripts) for
* a list of available StackScripts.
* - The Linode will be `running` after it completes `provisioning`.
* - Requires a compatible Image to be supplied.
* - See [/linode/stackscript/{stackscriptId}](/#operation/getStackScript) for compatible Images.
* - Requires a `root_pass` be supplied to use for the root User's Account.
* - It is recommended to supply SSH keys for the root User using the `authorized_keys` field.
*
* - Using one of your other Linode's backups.
* - You must create a Linode large enough to accommodate the Backup's size.
* - The Disks and Config will match that of the Linode that was backed up.
* - The `root_pass` will match that of the Linode that was backed up.
*
* - Create an empty Linode.
* - The Linode will remain `offline` and must be manually started.
* - See [POST /linode/instances/{linodeId}/boot](/#operation/bootLinodeInstance).
* - Disks and Configs must be created manually.
* - This is only recommended for advanced use cases.
*
* @param array $optional
* - [image=null]
* - [root_pass=null]
* - [authorized_keys=null]
* - [stackscript_id=null]
* - [stackscript_data=null]
* - [booted=null] (boolean) This field defaults to `true` if the Linode is created
* with an Image or from a Backup.
* If it is deployed from an Image or a Backup and you wish
* it to remain `offline` after deployment, set this to
* `false`.
* - [label=null] (string) The Linode's label is for display purposes only. If no
* label is provided for a Linode, a default will be
* assigned.
* Linode labels have the following constraints: Must
* start with an alpha character. Must consist of
* alphanumeric characters, dashes (`-`), and underscores
* (`_`). Cannot have two dashes (`--`) or underscores
* (`__`) in a row.
* - [group=null] (string) A deprecated property denoting a group label for this
* Linode.
* - [type=null]
* - [region=null]
* - [backup_id=null] (integer) A Backup ID from another Linode's available backups.
* Your User must have
* `read_write` access to that Linode, the Backup must have
* a `status` of
* `successful`, and the Linode must be deployed to the
* same `region` as the Backup.
* See
* [/linode/instances/{linodeId}/backups](/#operation/getBackups)
* for a Linode's available backups. This field and the
* `image` field are mutually exclusive.
* - [backups_enabled=null] (boolean) If this field is set to `true`, the created Linode will
* automatically be
* enrolled in the Linode Backup service. This will incur
* an additional charge.
* The cost for the Backup service is dependent on the Type
* of Linode deployed. Backup pricing is included in the
* response from
* [/linodes/types](/#operation/getLinodeTypes)
* - [swap_size=null] (integer) When deploying from an Image, this field is optional,
* otherwise it is ignored. This is used to set the swap
* disk size for the newly-created Linode.
*
* @link https://developers.linode.com/api/v4#operation/createLinodeInstance
*
* @return mixed
*/
public function create($optional = [])
{
return $this->apiCall('post', '', ['json' => array_merge([
], $optional)]);
}
}