Overview
TheUpdateResourceAction class handles updating existing resources in NetBird. It modifies the resource via the NetBird API and logs the changes for audit purposes.
Constructor Dependencies
The action is instantiated with the following dependency:Service class for interacting with the NetBird API
Method Signature
Parameters
The NetBird resource ID to update
The updated name of the resource
The updated network address of the resource
Optional updated description. Can be
nullWhether the resource should be enabled
The NetBird group ID to associate the resource with
The user performing the action (used for audit logging)
Return Value
Returns an array containing the updated resource data from NetBird:
The unique NetBird resource ID
The updated resource name
The updated resource network address
The updated resource description (nullable)
Whether the resource is enabled
Side Effects
This action performs the following side effects:- NetBird API Call: Updates the resource in NetBird via
NetbirdService::updateResource() - Audit Log: Creates a
ResourceLogentry with action typeUpdatedand tracks all changed attributes
Unlike
CreateResourceAction, this action does not modify the local Resource database table. The local table only stores the NetBird ID mapping and creation metadata.Example Usage
Error Scenarios
All update operations are logged with the complete new state of the resource, not just the changed fields. This ensures the audit log provides a complete history.
Source Reference
Implementation:/home/daytona/workspace/source/app/Actions/UpdateResourceAction.php:23