# VdsNodeEvent events

> 10 FeatherPanel plugin events on VdsNodeEvent (10 emitted by the core): the event names, the arguments each listener gets, where they fire and a PHP listener for each.

Source: https://featherpanel.com/docs/plugins/events/vds-node/

Part of the [plugin events reference](https://featherpanel.com/docs/plugins/events/). Listeners get the payload values as positional arguments in the order shown, cannot cancel the action, and must catch their own exceptions.

## Setup

Import `VdsNodeEvent` in your entry class and register listeners in `processEvents()`:

```php
<?php

namespace App\Addons\myplugin;

use App\App;
use App\Plugins\AppPlugin;
use App\Plugins\PluginEvents;
use App\Plugins\Events\Events\VdsNodeEvent;

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(VdsNodeEvent::onVdsNodeCreated(), function ($userUuid, $vmNodeId, $vmNode, $context): void {
            App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:vds:node:create ' . json_encode(['user_uuid' => $userUuid, 'vm_node_id' => $vmNodeId, 'vm_node' => $vmNode, 'context' => $context]));
        });
    }

    public static function pluginInstall(): void
    {
    }

    public static function pluginUninstall(): void
    {
    }
}
```

## `VdsNodeEvent::onVdsNodeCreated()`

- Name: `featherpanel:vds:node:create`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/VdsNodeEvent.php#L27)

Docblock: string|null user uuid, int vm node id, array node payload, array context.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `user_uuid` | `$userUuid` | `string|null`from docblock |
| 2 | `vm_node_id` | `$vmNodeId` | `int` |
| 3 | `vm_node` | `$vmNode` | `array`from docblock |
| 4 | `context` | `$context` | `array` |

When it fires (1 site)

-   [`VmNodesController::create`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/VmNodesController.php#L369) via `emitVdsEvent()`[`PUT /api/admin/vm-nodes`](https://featherpanel.com/docs/api/reference/admin/vm-nodes/#put-admin-vm-nodes)

```php
$event->on(VdsNodeEvent::onVdsNodeCreated(), function ($userUuid, $vmNodeId, $vmNode, $context): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:vds:node:create ' . json_encode(['user_uuid' => $userUuid, 'vm_node_id' => $vmNodeId, 'vm_node' => $vmNode, 'context' => $context]));
});
```

## `VdsNodeEvent::onVdsNodeDeleted()`

- Name: `featherpanel:vds:node:delete`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/VdsNodeEvent.php#L43)

Docblock: string|null user uuid, int vm node id, array node payload, array context.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `user_uuid` | `$userUuid` | `string|null`from docblock |
| 2 | `vm_node_id` | `$vmNodeId` | `int` |
| 3 | `vm_node` | `$vmNode` | `array`from docblock |
| 4 | `context` | `$context` | `array` |

When it fires (1 site)

-   [`VmNodesController::delete`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/VmNodesController.php#L566) via `emitVdsEvent()`[`DELETE /api/admin/vm-nodes/{id}`](https://featherpanel.com/docs/api/reference/admin/vm-nodes/#delete-admin-vm-nodes-id)

```php
$event->on(VdsNodeEvent::onVdsNodeDeleted(), function ($userUuid, $vmNodeId, $vmNode, $context): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:vds:node:delete ' . json_encode(['user_uuid' => $userUuid, 'vm_node_id' => $vmNodeId, 'vm_node' => $vmNode, 'context' => $context]));
});
```

## `VdsNodeEvent::onVdsNodeIpCreated()`

- Name: `featherpanel:vds:node:ip:create`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/VdsNodeEvent.php#L51)

Docblock: string|null user uuid, int vm node id, int ip id, array ip payload, array context.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `user_uuid` | `$userUuid` | `string|null`from docblock |
| 2 | `vm_node_id` | `$vmNodeId` | `int` |
| 3 | `ip_id` | `$ipId` | `int` |
| 4 | `ip` | `$ip` | `array`from docblock |
| 5 | `context` | `$context` | `array` |

When it fires (1 site)

-   [`VmNodesController::createIp`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/VmNodesController.php#L1355) via `emitVdsEvent()`[`PUT /api/admin/vm-nodes/{id}/ips`](https://featherpanel.com/docs/api/reference/admin/vm-nodes/#put-admin-vm-nodes-id-ips)

```php
$event->on(VdsNodeEvent::onVdsNodeIpCreated(), function ($userUuid, $vmNodeId, $ipId, $ip, $context): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:vds:node:ip:create ' . json_encode(['user_uuid' => $userUuid, 'vm_node_id' => $vmNodeId, 'ip_id' => $ipId, 'ip' => $ip, 'context' => $context]));
});
```

## `VdsNodeEvent::onVdsNodeIpDeleted()`

- Name: `featherpanel:vds:node:ip:delete`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/VdsNodeEvent.php#L67)

Docblock: string|null user uuid, int vm node id, int ip id, array ip payload, array context.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `user_uuid` | `$userUuid` | `string|null`from docblock |
| 2 | `vm_node_id` | `$vmNodeId` | `int` |
| 3 | `ip_id` | `$ipId` | `int` |
| 4 | `ip` | `$ip` | `array`from docblock |
| 5 | `context` | `$context` | `array` |

When it fires (1 site)

-   [`VmNodesController::deleteIp`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/VmNodesController.php#L1515) via `emitVdsEvent()`[`DELETE /api/admin/vm-nodes/{id}/ips/{ipId}`](https://featherpanel.com/docs/api/reference/admin/vm-nodes/#delete-admin-vm-nodes-id-ips-ipId)

```php
$event->on(VdsNodeEvent::onVdsNodeIpDeleted(), function ($userUuid, $vmNodeId, $ipId, $ip, $context): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:vds:node:ip:delete ' . json_encode(['user_uuid' => $userUuid, 'vm_node_id' => $vmNodeId, 'ip_id' => $ipId, 'ip' => $ip, 'context' => $context]));
});
```

## `VdsNodeEvent::onVdsNodeIpPrimarySet()`

- Name: `featherpanel:vds:node:ip:primary`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/VdsNodeEvent.php#L75)

Docblock: string|null user uuid, int vm node id, int ip id, array ip payload, array context.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `user_uuid` | `$userUuid` | `string|null`from docblock |
| 2 | `vm_node_id` | `$vmNodeId` | `int` |
| 3 | `ip_id` | `$ipId` | `int` |
| 4 | `ip` | `$ip` | `array`from docblock |
| 5 | `context` | `$context` | `array` |

When it fires (1 site)

-   [`VmNodesController::setPrimaryIp`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/VmNodesController.php#L1585) via `emitVdsEvent()`[`POST /api/admin/vm-nodes/{id}/ips/{ipId}/primary`](https://featherpanel.com/docs/api/reference/admin/vm-nodes/#post-admin-vm-nodes-id-ips-ipId-primary)

```php
$event->on(VdsNodeEvent::onVdsNodeIpPrimarySet(), function ($userUuid, $vmNodeId, $ipId, $ip, $context): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:vds:node:ip:primary ' . json_encode(['user_uuid' => $userUuid, 'vm_node_id' => $vmNodeId, 'ip_id' => $ipId, 'ip' => $ip, 'context' => $context]));
});
```

## `VdsNodeEvent::onVdsNodeIpUpdated()`

- Name: `featherpanel:vds:node:ip:update`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/VdsNodeEvent.php#L59)

Docblock: string|null user uuid, int vm node id, int ip id, array ip payload, array changed fields, array context.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `user_uuid` | `$userUuid` | `string|null`from docblock |
| 2 | `vm_node_id` | `$vmNodeId` | `int` |
| 3 | `ip_id` | `$ipId` | `int` |
| 4 | `ip` | `$ip` | `array`from docblock |
| 5 | `changed_fields` | `$changedFields` | `array` |
| 6 | `context` | `$context` | `array` |

When it fires (1 site)

-   [`VmNodesController::updateIp`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/VmNodesController.php#L1446) via `emitVdsEvent()`[`PATCH /api/admin/vm-nodes/{id}/ips/{ipId}`](https://featherpanel.com/docs/api/reference/admin/vm-nodes/#patch-admin-vm-nodes-id-ips-ipId)

```php
$event->on(VdsNodeEvent::onVdsNodeIpUpdated(), function ($userUuid, $vmNodeId, $ipId, $ip, $changedFields, $context): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:vds:node:ip:update ' . json_encode(['user_uuid' => $userUuid, 'vm_node_id' => $vmNodeId, 'ip_id' => $ipId, 'ip' => $ip, 'changed_fields' => $changedFields, 'context' => $context]));
});
```

## `VdsNodeEvent::onVdsNodeUpdated()`

- Name: `featherpanel:vds:node:update`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/VdsNodeEvent.php#L35)

Docblock: string|null user uuid, int vm node id, array node payload, array changed fields, array context.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `user_uuid` | `$userUuid` | `string|null`from docblock |
| 2 | `vm_node_id` | `$vmNodeId` | `int` |
| 3 | `vm_node` | `$vmNode` | `array`from docblock |
| 4 | `changed_fields` | `$changedFields` | `array` |
| 5 | `context` | `$context` | `array` |

When it fires (1 site)

-   [`VmNodesController::update`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/VmNodesController.php#L491) via `emitVdsEvent()`[`PATCH /api/admin/vm-nodes/{id}`](https://featherpanel.com/docs/api/reference/admin/vm-nodes/#patch-admin-vm-nodes-id)

```php
$event->on(VdsNodeEvent::onVdsNodeUpdated(), function ($userUuid, $vmNodeId, $vmNode, $changedFields, $context): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:vds:node:update ' . json_encode(['user_uuid' => $userUuid, 'vm_node_id' => $vmNodeId, 'vm_node' => $vmNode, 'changed_fields' => $changedFields, 'context' => $context]));
});
```

## `VdsNodeEvent::onVdsTemplateCreated()`

- Name: `featherpanel:vds:template:create`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/VdsNodeEvent.php#L83)

Docblock: string|null user uuid, int template id, int vm node id, array template payload, array context.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `user_uuid` | `$userUuid` | `string|null`from docblock |
| 2 | `template_id` | `$templateId` | `int`from docblock |
| 3 | `vm_node_id` | `$vmNodeId` | `int` |
| 4 | `template` | `$template` | `array`from docblock |
| 5 | `context` | `$context` | `array` |

When it fires (1 site)

-   [`VmNodesController::createTemplate`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/VmNodesController.php#L1660) via `emitVdsEvent()`[`POST /api/admin/vm-nodes/{id}/templates`](https://featherpanel.com/docs/api/reference/admin/vm-nodes/#post-admin-vm-nodes-id-templates)

```php
$event->on(VdsNodeEvent::onVdsTemplateCreated(), function ($userUuid, $templateId, $vmNodeId, $template, $context): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:vds:template:create ' . json_encode(['user_uuid' => $userUuid, 'template_id' => $templateId, 'vm_node_id' => $vmNodeId, 'template' => $template, 'context' => $context]));
});
```

## `VdsNodeEvent::onVdsTemplateDeleted()`

- Name: `featherpanel:vds:template:delete`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/VdsNodeEvent.php#L99)

Docblock: string|null user uuid, int template id, int vm node id, array template payload, array context.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `user_uuid` | `$userUuid` | `string|null`from docblock |
| 2 | `template_id` | `$templateId` | `int` |
| 3 | `vm_node_id` | `$vmNodeId` | `int`from docblock |
| 4 | `template` | `$template` | `array`from docblock |
| 5 | `context` | `$context` | `array` |

When it fires (1 site)

-   [`VmNodesController::deleteTemplate`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/VmNodesController.php#L1720) via `emitVdsEvent()`[`DELETE /api/admin/vm-templates/{id}`](https://featherpanel.com/docs/api/reference/admin/vm-templates/#delete-admin-vm-templates-id)

```php
$event->on(VdsNodeEvent::onVdsTemplateDeleted(), function ($userUuid, $templateId, $vmNodeId, $template, $context): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:vds:template:delete ' . json_encode(['user_uuid' => $userUuid, 'template_id' => $templateId, 'vm_node_id' => $vmNodeId, 'template' => $template, 'context' => $context]));
});
```

## `VdsNodeEvent::onVdsTemplateUpdated()`

- Name: `featherpanel:vds:template:update`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/VdsNodeEvent.php#L91)

Docblock: string|null user uuid, int template id, int vm node id, array template payload, array changed fields, array context.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `user_uuid` | `$userUuid` | `string|null`from docblock |
| 2 | `template_id` | `$templateId` | `int` |
| 3 | `vm_node_id` | `$vmNodeId` | `int`from docblock |
| 4 | `template` | `$template` | `array`from docblock |
| 5 | `changed_fields` | `$changedFields` | `array` |
| 6 | `context` | `$context` | `array` |

When it fires (1 site)

-   [`VmNodesController::updateTemplate`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/VmNodesController.php#L1692) via `emitVdsEvent()`[`PATCH /api/admin/vm-templates/{id}`](https://featherpanel.com/docs/api/reference/admin/vm-templates/#patch-admin-vm-templates-id)

```php
$event->on(VdsNodeEvent::onVdsTemplateUpdated(), function ($userUuid, $templateId, $vmNodeId, $template, $changedFields, $context): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:vds:template:update ' . json_encode(['user_uuid' => $userUuid, 'template_id' => $templateId, 'vm_node_id' => $vmNodeId, 'template' => $template, 'changed_fields' => $changedFields, 'context' => $context]));
});
```
