diff --git a/app/Extensions/Scribe/OpenApi/PterodactylOpenApiGenerator.php b/app/Extensions/Scribe/OpenApi/PterodactylOpenApiGenerator.php index 40d430b92..46e0ddb9d 100644 --- a/app/Extensions/Scribe/OpenApi/PterodactylOpenApiGenerator.php +++ b/app/Extensions/Scribe/OpenApi/PterodactylOpenApiGenerator.php @@ -1854,6 +1854,7 @@ class PterodactylOpenApiGenerator extends OpenApiGenerator $mapped = match ($relationship) { 'allocations' => 'allocation', + 'deployment_tags' => 'tag', 'tasks' => 'schedule_task', 'variables' => 'egg_variable', default => null, diff --git a/app/Http/Controllers/Api/Admin/Nodes/NodeController.php b/app/Http/Controllers/Api/Admin/Nodes/NodeController.php index 5c70a1bc5..de0a00021 100644 --- a/app/Http/Controllers/Api/Admin/Nodes/NodeController.php +++ b/app/Http/Controllers/Api/Admin/Nodes/NodeController.php @@ -53,7 +53,7 @@ class NodeController extends AdminApiController #[QueryParam('sort', 'string', 'Sort nodes by id, uuid, name, memory, disk, or creation time. Prefix with a hyphen for descending order.', required: false, example: '-created_at')] #[QueryParam('page', 'integer', 'Page number to return.', required: false, example: 1)] #[QueryParam('per_page', 'integer', 'Results to return per page.', required: false, example: 50)] - #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "allocations", "location", and "servers".', required: false, example: 'location', enum: ['allocations', 'location', 'servers', 'allocations,location', 'location,servers'])] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations).', required: false, example: 'location', enum: ['allocations', 'location', 'servers', 'allocations,location', 'location,servers', 'tags', 'deployment_tags', 'tags,deployment_tags'])] #[ResponseFromResource(NodeResource::class, Node::class, description: 'Nodes returned.', collection: true, factoryStates: ['withLocation'], resourceKey: 'node', paginate: 50, withCount: ['servers'])] public function index(GetNodesRequest $request): ApiResourceCollection { @@ -69,8 +69,8 @@ class NodeController extends AdminApiController * Show node. */ #[Endpoint('Get node', 'Returns a single Wings node by ID.')] - #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "allocations", "location", and "servers".', required: false, example: 'location', enum: ['allocations', 'location', 'servers', 'allocations,location', 'location,servers'])] - #[ResponseFromResource(NodeResource::class, Node::class, description: 'Node returned.', factoryStates: ['withLocation'], resourceKey: 'node', include: ['location'], withCount: ['servers'])] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations).', required: false, example: 'location', enum: ['allocations', 'location', 'servers', 'allocations,location', 'location,servers', 'tags', 'deployment_tags', 'tags,deployment_tags'])] + #[ResponseFromResource(NodeResource::class, Node::class, description: 'Node returned.', factoryStates: ['withLocation'], resourceKey: 'node', include: ['location', 'tags', 'deployment_tags'], withCount: ['servers'])] public function show(GetNodeRequest $request, Node $node): NodeResource { $node->loadCount('servers'); diff --git a/app/Http/Controllers/Api/Application/Nodes/NodeController.php b/app/Http/Controllers/Api/Application/Nodes/NodeController.php index 84f0c28fd..fb793effd 100644 --- a/app/Http/Controllers/Api/Application/Nodes/NodeController.php +++ b/app/Http/Controllers/Api/Application/Nodes/NodeController.php @@ -62,7 +62,7 @@ class NodeController extends ApplicationApiController #[QueryParam('filter[fqdn]', 'string', 'Filter nodes by fully qualified domain name.', required: false, example: 'node.example.com')] #[QueryParam('filter[daemon_token_id]', 'string', 'Filter nodes by daemon token identifier.', required: false, example: 'abcdefghijklmnop')] #[QueryParam('sort', 'string', 'Sort nodes by id, uuid, memory, or disk. Prefix with "-" for descending order.', required: false, example: '-id', enum: ['id', '-id', 'uuid', '-uuid', 'memory', '-memory', 'disk', '-disk'])] - #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "allocations", "location", and "servers" when the key can read those resources.', required: false, example: 'location,allocations', enum: ['allocations', 'location', 'servers', 'location,allocations'])] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations) when the key can read those resources. The tags need read access to eggs.', required: false, example: 'location,allocations', enum: ['allocations', 'location', 'servers', 'location,allocations', 'tags', 'deployment_tags', 'tags,deployment_tags'])] #[ResponseFromResource(NodeResource::class, Node::class, collection: true, factoryStates: ['withLocation'], resourceKey: 'node', paginate: 50)] public function index(GetNodesRequest $request): ApiResourceCollection { @@ -80,7 +80,7 @@ class NodeController extends ApplicationApiController * Return data for a single instance of a node. */ #[Endpoint('Get node', 'Returns a single Wings node by internal numeric ID.')] - #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "allocations", "location", and "servers" when the key can read those resources.', required: false, example: 'location,allocations', enum: ['allocations', 'location', 'servers', 'location,allocations'])] + #[QueryParam('include', 'string', 'Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations) when the key can read those resources. The tags need read access to eggs.', required: false, example: 'location,allocations', enum: ['allocations', 'location', 'servers', 'location,allocations', 'tags', 'deployment_tags', 'tags,deployment_tags'])] #[ResponseFromResource(NodeResource::class, Node::class, factoryStates: ['withLocation'], resourceKey: 'node')] public function view(GetNodeRequest $request, Node $node): NodeResource { diff --git a/app/Http/Resources/Api/Admin/NodeResource.php b/app/Http/Resources/Api/Admin/NodeResource.php index e72c94419..689390e97 100644 --- a/app/Http/Resources/Api/Admin/NodeResource.php +++ b/app/Http/Resources/Api/Admin/NodeResource.php @@ -12,6 +12,7 @@ use Pterodactyl\Http\Resources\Api\ApiResourceCollection; use Pterodactyl\Http\Resources\Api\Includes\IncludedResource; use Pterodactyl\Models\Location; use Pterodactyl\Models\Node; +use Pterodactyl\Models\Tag; /** * @extends AdminResource @@ -25,9 +26,11 @@ class NodeResource extends AdminResource 'allocations' => ['relation' => 'allocations', 'resource' => AllocationResource::class], 'location' => ['relation' => 'location', 'resource' => LocationResource::class], 'servers' => ['relation' => 'servers', 'resource' => ServerResource::class], + 'tags' => ['relation' => 'eggTags', 'resource' => TagResource::class], + 'deployment_tags' => ['relation' => 'deploymentTags', 'resource' => TagResource::class], ]; - protected array $availableIncludes = ['allocations', 'location', 'servers']; + protected array $availableIncludes = ['allocations', 'location', 'servers', 'tags', 'deployment_tags']; public function resourceName(): string { @@ -62,6 +65,8 @@ class NodeResource extends AdminResource 'allocations' => $this->includeAllocations(), 'location' => $this->includeLocation(), 'servers' => $this->includeServers(), + 'tags' => $this->includeTags(), + 'deployment_tags' => $this->includeDeploymentTags(), default => parent::resolveInclude($include), }; } @@ -83,4 +88,14 @@ class NodeResource extends AdminResource { return $this->items($this->resource->loadMissing('servers')->servers, ServerResource::class, 'server'); } + + private function includeTags(): ApiResourceCollection + { + return $this->items($this->resource->loadMissing('eggTags')->eggTags, TagResource::class, Tag::RESOURCE_NAME); + } + + private function includeDeploymentTags(): ApiResourceCollection + { + return $this->items($this->resource->loadMissing('deploymentTags')->deploymentTags, TagResource::class, Tag::RESOURCE_NAME); + } } diff --git a/app/Http/Resources/Api/Application/NodeResource.php b/app/Http/Resources/Api/Application/NodeResource.php index 5f01a70ad..5703f643b 100644 --- a/app/Http/Resources/Api/Application/NodeResource.php +++ b/app/Http/Resources/Api/Application/NodeResource.php @@ -12,6 +12,7 @@ use Pterodactyl\Http\Resources\Api\Includes\IncludedResource; use Pterodactyl\Http\Resources\Api\NullResource; use Pterodactyl\Models\Location; use Pterodactyl\Models\Node; +use Pterodactyl\Models\Tag; use Pterodactyl\Services\Acl\Api\AdminAcl; /** @@ -25,9 +26,11 @@ class NodeResource extends ApplicationResource 'allocations' => ['relation' => 'allocations', 'resource' => AllocationResource::class, 'ability' => AdminAcl::RESOURCE_ALLOCATIONS], 'location' => ['relation' => 'location', 'resource' => LocationResource::class, 'ability' => AdminAcl::RESOURCE_LOCATIONS], 'servers' => ['relation' => 'servers', 'resource' => ServerResource::class, 'ability' => AdminAcl::RESOURCE_SERVERS], + 'tags' => ['relation' => 'eggTags', 'resource' => TagResource::class, 'ability' => AdminAcl::RESOURCE_EGGS], + 'deployment_tags' => ['relation' => 'deploymentTags', 'resource' => TagResource::class, 'ability' => AdminAcl::RESOURCE_EGGS], ]; - protected array $availableIncludes = ['allocations', 'location', 'servers']; + protected array $availableIncludes = ['allocations', 'location', 'servers', 'tags', 'deployment_tags']; public function resourceName(): string { @@ -62,6 +65,8 @@ class NodeResource extends ApplicationResource 'allocations' => $this->includeAllocations(), 'location' => $this->includeLocation(), 'servers' => $this->includeServers(), + 'tags' => $this->includeTags(), + 'deployment_tags' => $this->includeDeploymentTags(), default => parent::resolveInclude($include), }; } @@ -95,4 +100,22 @@ class NodeResource extends ApplicationResource return $this->items($this->resource->loadMissing('servers')->servers, ServerResource::class, 'server'); } + + private function includeTags(): ApiResourceCollection|NullResource + { + if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) { + return $this->null(); + } + + return $this->items($this->resource->loadMissing('eggTags')->eggTags, TagResource::class, Tag::RESOURCE_NAME); + } + + private function includeDeploymentTags(): ApiResourceCollection|NullResource + { + if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) { + return $this->null(); + } + + return $this->items($this->resource->loadMissing('deploymentTags')->deploymentTags, TagResource::class, Tag::RESOURCE_NAME); + } } diff --git a/packages/sdk/types/api/generated/types.gen.d.ts b/packages/sdk/types/api/generated/types.gen.d.ts index cae1b84f6..1bc28a82c 100644 --- a/packages/sdk/types/api/generated/types.gen.d.ts +++ b/packages/sdk/types/api/generated/types.gen.d.ts @@ -397,6 +397,8 @@ export type AdminNodeAttributes = { extensions?: ExtensionFields; relationships?: { location?: AdminLocationResource | NullResource; + tags?: AdminTagListResponse | NullResource; + deployment_tags?: AdminTagListResponse | NullResource; }; }; export type AdminNodeConfigurationResponse = { @@ -3898,13 +3900,13 @@ export type AdminListNodesPageQueryParameter = number; */ export type AdminListNodesPerPageQueryParameter = number; /** - * Comma-separated relationships to include. Supports "allocations", "location", and "servers". + * Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations). */ -export type AdminListNodesIncludeQueryParameter = 'allocations' | 'location' | 'servers' | 'allocations,location' | 'location,servers'; +export type AdminListNodesIncludeQueryParameter = 'allocations' | 'location' | 'servers' | 'allocations,location' | 'location,servers' | 'tags' | 'deployment_tags' | 'tags,deployment_tags'; /** - * Comma-separated relationships to include. Supports "allocations", "location", and "servers". + * Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations). */ -export type AdminGetNodeIncludeQueryParameter = 'allocations' | 'location' | 'servers' | 'allocations,location' | 'location,servers'; +export type AdminGetNodeIncludeQueryParameter = 'allocations' | 'location' | 'servers' | 'allocations,location' | 'location,servers' | 'tags' | 'deployment_tags' | 'tags,deployment_tags'; export type AdminGetNodeNodeIdPathParameter = number; export type AdminGetNodeConfigurationNodeIdPathParameter = number; export type AdminSyncNodeGameTagsNodeIdPathParameter = number; @@ -4212,9 +4214,9 @@ export type ApplicationListNodesFilterDaemonTokenIdQueryParameter = string; */ export type ApplicationListNodesSortQueryParameter = 'id' | '-id' | 'uuid' | '-uuid' | 'memory' | '-memory' | 'disk' | '-disk'; /** - * Comma-separated relationships to include. Supports "allocations", "location", and "servers" when the key can read those resources. + * Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations) when the key can read those resources. The tags need read access to eggs. */ -export type ApplicationListNodesIncludeQueryParameter = 'allocations' | 'location' | 'servers' | 'location,allocations'; +export type ApplicationListNodesIncludeQueryParameter = 'allocations' | 'location' | 'servers' | 'location,allocations' | 'tags' | 'deployment_tags' | 'tags,deployment_tags'; /** * Memory required for the deployment, in megabytes. */ @@ -4236,9 +4238,9 @@ export type ApplicationListDeployableNodesPageQueryParameter = number; */ export type ApplicationListDeployableNodesPerPageQueryParameter = number; /** - * Comma-separated relationships to include. Supports "allocations", "location", and "servers" when the key can read those resources. + * Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations) when the key can read those resources. The tags need read access to eggs. */ -export type ApplicationGetNodeIncludeQueryParameter = 'allocations' | 'location' | 'servers' | 'location,allocations'; +export type ApplicationGetNodeIncludeQueryParameter = 'allocations' | 'location' | 'servers' | 'location,allocations' | 'tags' | 'deployment_tags' | 'tags,deployment_tags'; export type ApplicationGetNodeNodeIdPathParameter = number; export type ApplicationGetNodeConfigurationNodeIdPathParameter = number; /** @@ -6437,7 +6439,7 @@ export type AdminListNodesData = { */ per_page?: AdminListNodesPerPageQueryParameter; /** - * Comma-separated relationships to include. Supports "allocations", "location", and "servers". + * Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations). */ include?: AdminListNodesIncludeQueryParameter; }; @@ -6536,7 +6538,7 @@ export type AdminGetNodeData = { }; query?: { /** - * Comma-separated relationships to include. Supports "allocations", "location", and "servers". + * Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations). */ include?: AdminGetNodeIncludeQueryParameter; }; @@ -9286,7 +9288,7 @@ export type ApplicationListNodesData = { */ sort?: ApplicationListNodesSortQueryParameter; /** - * Comma-separated relationships to include. Supports "allocations", "location", and "servers" when the key can read those resources. + * Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations) when the key can read those resources. The tags need read access to eggs. */ include?: ApplicationListNodesIncludeQueryParameter; }; @@ -9435,7 +9437,7 @@ export type ApplicationGetNodeData = { }; query?: { /** - * Comma-separated relationships to include. Supports "allocations", "location", and "servers" when the key can read those resources. + * Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations) when the key can read those resources. The tags need read access to eggs. */ include?: ApplicationGetNodeIncludeQueryParameter; }; diff --git a/resources/scripts/api/generated/types.gen.ts b/resources/scripts/api/generated/types.gen.ts index 95eb614bf..b5dd7f370 100644 --- a/resources/scripts/api/generated/types.gen.ts +++ b/resources/scripts/api/generated/types.gen.ts @@ -441,6 +441,8 @@ export type AdminNodeAttributes = { extensions?: ExtensionFields; relationships?: { location?: AdminLocationResource | NullResource; + tags?: AdminTagListResponse | NullResource; + deployment_tags?: AdminTagListResponse | NullResource; }; }; @@ -4249,14 +4251,14 @@ export type AdminListNodesPageQueryParameter = number; export type AdminListNodesPerPageQueryParameter = number; /** - * Comma-separated relationships to include. Supports "allocations", "location", and "servers". + * Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations). */ -export type AdminListNodesIncludeQueryParameter = 'allocations' | 'location' | 'servers' | 'allocations,location' | 'location,servers'; +export type AdminListNodesIncludeQueryParameter = 'allocations' | 'location' | 'servers' | 'allocations,location' | 'location,servers' | 'tags' | 'deployment_tags' | 'tags,deployment_tags'; /** - * Comma-separated relationships to include. Supports "allocations", "location", and "servers". + * Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations). */ -export type AdminGetNodeIncludeQueryParameter = 'allocations' | 'location' | 'servers' | 'allocations,location' | 'location,servers'; +export type AdminGetNodeIncludeQueryParameter = 'allocations' | 'location' | 'servers' | 'allocations,location' | 'location,servers' | 'tags' | 'deployment_tags' | 'tags,deployment_tags'; export type AdminGetNodeNodeIdPathParameter = number; @@ -4667,9 +4669,9 @@ export type ApplicationListNodesFilterDaemonTokenIdQueryParameter = string; export type ApplicationListNodesSortQueryParameter = 'id' | '-id' | 'uuid' | '-uuid' | 'memory' | '-memory' | 'disk' | '-disk'; /** - * Comma-separated relationships to include. Supports "allocations", "location", and "servers" when the key can read those resources. + * Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations) when the key can read those resources. The tags need read access to eggs. */ -export type ApplicationListNodesIncludeQueryParameter = 'allocations' | 'location' | 'servers' | 'location,allocations'; +export type ApplicationListNodesIncludeQueryParameter = 'allocations' | 'location' | 'servers' | 'location,allocations' | 'tags' | 'deployment_tags' | 'tags,deployment_tags'; /** * Memory required for the deployment, in megabytes. @@ -4697,9 +4699,9 @@ export type ApplicationListDeployableNodesPageQueryParameter = number; export type ApplicationListDeployableNodesPerPageQueryParameter = number; /** - * Comma-separated relationships to include. Supports "allocations", "location", and "servers" when the key can read those resources. + * Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations) when the key can read those resources. The tags need read access to eggs. */ -export type ApplicationGetNodeIncludeQueryParameter = 'allocations' | 'location' | 'servers' | 'location,allocations'; +export type ApplicationGetNodeIncludeQueryParameter = 'allocations' | 'location' | 'servers' | 'location,allocations' | 'tags' | 'deployment_tags' | 'tags,deployment_tags'; export type ApplicationGetNodeNodeIdPathParameter = number; @@ -7303,7 +7305,7 @@ export type AdminListNodesData = { */ per_page?: AdminListNodesPerPageQueryParameter; /** - * Comma-separated relationships to include. Supports "allocations", "location", and "servers". + * Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations). */ include?: AdminListNodesIncludeQueryParameter; }; @@ -7417,7 +7419,7 @@ export type AdminGetNodeData = { }; query?: { /** - * Comma-separated relationships to include. Supports "allocations", "location", and "servers". + * Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations). */ include?: AdminGetNodeIncludeQueryParameter; }; @@ -10542,7 +10544,7 @@ export type ApplicationListNodesData = { */ sort?: ApplicationListNodesSortQueryParameter; /** - * Comma-separated relationships to include. Supports "allocations", "location", and "servers" when the key can read those resources. + * Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations) when the key can read those resources. The tags need read access to eggs. */ include?: ApplicationListNodesIncludeQueryParameter; }; @@ -10711,7 +10713,7 @@ export type ApplicationGetNodeData = { }; query?: { /** - * Comma-separated relationships to include. Supports "allocations", "location", and "servers" when the key can read those resources. + * Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations) when the key can read those resources. The tags need read access to eggs. */ include?: ApplicationGetNodeIncludeQueryParameter; }; diff --git a/tests/.pest/snapshots/Integration/Api/Snapshots/AdminResponseSnapshotTest/admin_api_responses_match_their_snapshots_with_data_set__dataset__nodes_tags__.snap b/tests/.pest/snapshots/Integration/Api/Snapshots/AdminResponseSnapshotTest/admin_api_responses_match_their_snapshots_with_data_set__dataset__nodes_tags__.snap new file mode 100644 index 000000000..a85123910 --- /dev/null +++ b/tests/.pest/snapshots/Integration/Api/Snapshots/AdminResponseSnapshotTest/admin_api_responses_match_their_snapshots_with_data_set__dataset__nodes_tags__.snap @@ -0,0 +1,11 @@ +GET /api/admin/nodes?include=tags,deployment_tags +200 application/json +{"object":"list","data":[{"object":"node","attributes":{"id":1,"uuid":"d0de0001-0000-4000-8000-000000000001","public":true,"name":"node-alpha","description":"Primary \"alpha\" node","location_id":1,"fqdn":"alpha.example.test","scheme":"https","behind_proxy":false,"maintenance_mode":false,"memory":8192,"memory_overallocate":0,"disk":102400,"disk_overallocate":-1,"upload_size":100,"daemon_listen":8080,"daemon_sftp":2022,"daemon_base":"\/var\/lib\/pterodactyl\/volumes","created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00","servers_count":2,"allocated_resources":{"memory":3072,"disk":15360},"relationships":{"tags":{"object":"list","data":[{"object":"tag","attributes":{"id":1,"name":"Minecraft","slug":"minecraft","color":"#5B8731","is_predefined":true,"legacy_nest_id":1,"eggs_count":0,"nodes_count":0,"created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00"}}]},"deployment_tags":{"object":"list","data":[]}}}},{"object":"node","attributes":{"id":2,"uuid":"d0de0002-0000-4000-8000-000000000002","public":false,"name":"node-beta","description":null,"location_id":2,"fqdn":"beta.example.test","scheme":"http","behind_proxy":true,"maintenance_mode":true,"memory":4096,"memory_overallocate":10,"disk":51200,"disk_overallocate":0,"upload_size":256,"daemon_listen":8443,"daemon_sftp":2222,"daemon_base":"\/srv\/daemon-data","created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00","servers_count":1,"allocated_resources":{"memory":512,"disk":1024},"relationships":{"tags":{"object":"list","data":[]},"deployment_tags":{"object":"list","data":[{"object":"tag","attributes":{"id":3,"name":"Reserved","slug":"reserved","color":null,"is_predefined":false,"legacy_nest_id":null,"eggs_count":0,"nodes_count":0,"created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00"}}]}}}}],"meta":{"pagination":{"total":2,"count":2,"per_page":50,"current_page":1,"total_pages":1,"links":{}}}} + +GET /api/admin/nodes/1?include=tags +200 application/json +{"object":"node","attributes":{"id":1,"uuid":"d0de0001-0000-4000-8000-000000000001","public":true,"name":"node-alpha","description":"Primary \"alpha\" node","location_id":1,"fqdn":"alpha.example.test","scheme":"https","behind_proxy":false,"maintenance_mode":false,"memory":8192,"memory_overallocate":0,"disk":102400,"disk_overallocate":-1,"upload_size":100,"daemon_listen":8080,"daemon_sftp":2022,"daemon_base":"\/var\/lib\/pterodactyl\/volumes","created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00","servers_count":2,"allocated_resources":{"memory":3072,"disk":15360},"relationships":{"tags":{"object":"list","data":[{"object":"tag","attributes":{"id":1,"name":"Minecraft","slug":"minecraft","color":"#5B8731","is_predefined":true,"legacy_nest_id":1,"eggs_count":0,"nodes_count":0,"created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00"}}]}},"extensions":{}}} + +GET /api/admin/nodes/2?include=deployment_tags.nodes +200 application/json +{"object":"node","attributes":{"id":2,"uuid":"d0de0002-0000-4000-8000-000000000002","public":false,"name":"node-beta","description":null,"location_id":2,"fqdn":"beta.example.test","scheme":"http","behind_proxy":true,"maintenance_mode":true,"memory":4096,"memory_overallocate":10,"disk":51200,"disk_overallocate":0,"upload_size":256,"daemon_listen":8443,"daemon_sftp":2222,"daemon_base":"\/srv\/daemon-data","created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00","servers_count":1,"allocated_resources":{"memory":512,"disk":1024},"relationships":{"deployment_tags":{"object":"list","data":[{"object":"tag","attributes":{"id":3,"name":"Reserved","slug":"reserved","color":null,"is_predefined":false,"legacy_nest_id":null,"eggs_count":0,"nodes_count":0,"created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00","relationships":{"nodes":{"object":"list","data":[{"object":"node","attributes":{"id":2,"uuid":"d0de0002-0000-4000-8000-000000000002","public":false,"name":"node-beta","description":null,"location_id":2,"fqdn":"beta.example.test","scheme":"http","behind_proxy":true,"maintenance_mode":true,"memory":4096,"memory_overallocate":10,"disk":51200,"disk_overallocate":0,"upload_size":256,"daemon_listen":8443,"daemon_sftp":2222,"daemon_base":"\/srv\/daemon-data","created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00","allocated_resources":{"memory":512,"disk":1024},"relationships":[]}}]}}}}]}},"extensions":{}}} diff --git a/tests/.pest/snapshots/Integration/Api/Snapshots/ApplicationResponseSnapshotTest/application_api_responses_match_their_snapshots_with_data_set__dataset__nodes_tags__.snap b/tests/.pest/snapshots/Integration/Api/Snapshots/ApplicationResponseSnapshotTest/application_api_responses_match_their_snapshots_with_data_set__dataset__nodes_tags__.snap new file mode 100644 index 000000000..ffd7b6714 --- /dev/null +++ b/tests/.pest/snapshots/Integration/Api/Snapshots/ApplicationResponseSnapshotTest/application_api_responses_match_their_snapshots_with_data_set__dataset__nodes_tags__.snap @@ -0,0 +1,11 @@ +GET /api/application/nodes?include=tags,deployment_tags +200 application/json +{"object":"list","data":[{"object":"node","attributes":{"id":1,"uuid":"d0de0001-0000-4000-8000-000000000001","public":true,"name":"node-alpha","description":"Primary \"alpha\" node","location_id":1,"fqdn":"alpha.example.test","scheme":"https","behind_proxy":false,"maintenance_mode":false,"memory":8192,"memory_overallocate":0,"disk":102400,"disk_overallocate":-1,"upload_size":100,"daemon_listen":8080,"daemon_sftp":2022,"daemon_base":"\/var\/lib\/pterodactyl\/volumes","created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00","allocated_resources":{"memory":3072,"disk":15360},"relationships":{"tags":{"object":"list","data":[{"object":"tag","attributes":{"id":1,"name":"Minecraft","slug":"minecraft","color":"#5B8731","is_predefined":true,"legacy_nest_id":1,"relationships":[],"created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00"}}]},"deployment_tags":{"object":"list","data":[]}}}},{"object":"node","attributes":{"id":2,"uuid":"d0de0002-0000-4000-8000-000000000002","public":false,"name":"node-beta","description":null,"location_id":2,"fqdn":"beta.example.test","scheme":"http","behind_proxy":true,"maintenance_mode":true,"memory":4096,"memory_overallocate":10,"disk":51200,"disk_overallocate":0,"upload_size":256,"daemon_listen":8443,"daemon_sftp":2222,"daemon_base":"\/srv\/daemon-data","created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00","allocated_resources":{"memory":512,"disk":1024},"relationships":{"tags":{"object":"list","data":[]},"deployment_tags":{"object":"list","data":[{"object":"tag","attributes":{"id":3,"name":"Reserved","slug":"reserved","color":null,"is_predefined":false,"legacy_nest_id":null,"relationships":[],"created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00"}}]}}}}],"meta":{"pagination":{"total":2,"count":2,"per_page":50,"current_page":1,"total_pages":1,"links":{}}}} + +GET /api/application/nodes/1?include=tags +200 application/json +{"object":"node","attributes":{"id":1,"uuid":"d0de0001-0000-4000-8000-000000000001","public":true,"name":"node-alpha","description":"Primary \"alpha\" node","location_id":1,"fqdn":"alpha.example.test","scheme":"https","behind_proxy":false,"maintenance_mode":false,"memory":8192,"memory_overallocate":0,"disk":102400,"disk_overallocate":-1,"upload_size":100,"daemon_listen":8080,"daemon_sftp":2022,"daemon_base":"\/var\/lib\/pterodactyl\/volumes","created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00","allocated_resources":{"memory":3072,"disk":15360},"relationships":{"tags":{"object":"list","data":[{"object":"tag","attributes":{"id":1,"name":"Minecraft","slug":"minecraft","color":"#5B8731","is_predefined":true,"legacy_nest_id":1,"relationships":[],"created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00"}}]}},"extensions":{}}} + +GET /api/application/nodes/2?include=deployment_tags.nodes +200 application/json +{"object":"node","attributes":{"id":2,"uuid":"d0de0002-0000-4000-8000-000000000002","public":false,"name":"node-beta","description":null,"location_id":2,"fqdn":"beta.example.test","scheme":"http","behind_proxy":true,"maintenance_mode":true,"memory":4096,"memory_overallocate":10,"disk":51200,"disk_overallocate":0,"upload_size":256,"daemon_listen":8443,"daemon_sftp":2222,"daemon_base":"\/srv\/daemon-data","created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00","allocated_resources":{"memory":512,"disk":1024},"relationships":{"deployment_tags":{"object":"list","data":[{"object":"tag","attributes":{"id":3,"name":"Reserved","slug":"reserved","color":null,"is_predefined":false,"legacy_nest_id":null,"relationships":{"nodes":{"object":"list","data":[{"object":"node","attributes":{"id":2,"uuid":"d0de0002-0000-4000-8000-000000000002","public":false,"name":"node-beta","description":null,"location_id":2,"fqdn":"beta.example.test","scheme":"http","behind_proxy":true,"maintenance_mode":true,"memory":4096,"memory_overallocate":10,"disk":51200,"disk_overallocate":0,"upload_size":256,"daemon_listen":8443,"daemon_sftp":2222,"daemon_base":"\/srv\/daemon-data","created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00","allocated_resources":{"memory":512,"disk":1024},"relationships":[]}}]}},"created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00"}}]}},"extensions":{}}} diff --git a/tests/.pest/snapshots/Integration/Api/Snapshots/ApplicationResponseSnapshotTest/application_api_responses_match_their_snapshots_with_data_set__dataset__nodes_tags_without_eggs_access__.snap b/tests/.pest/snapshots/Integration/Api/Snapshots/ApplicationResponseSnapshotTest/application_api_responses_match_their_snapshots_with_data_set__dataset__nodes_tags_without_eggs_access__.snap new file mode 100644 index 000000000..c08aa98d7 --- /dev/null +++ b/tests/.pest/snapshots/Integration/Api/Snapshots/ApplicationResponseSnapshotTest/application_api_responses_match_their_snapshots_with_data_set__dataset__nodes_tags_without_eggs_access__.snap @@ -0,0 +1,3 @@ +GET /api/application/nodes/1?include=tags,deployment_tags +200 application/json +{"object":"node","attributes":{"id":1,"uuid":"d0de0001-0000-4000-8000-000000000001","public":true,"name":"node-alpha","description":"Primary \"alpha\" node","location_id":1,"fqdn":"alpha.example.test","scheme":"https","behind_proxy":false,"maintenance_mode":false,"memory":8192,"memory_overallocate":0,"disk":102400,"disk_overallocate":-1,"upload_size":100,"daemon_listen":8080,"daemon_sftp":2022,"daemon_base":"\/var\/lib\/pterodactyl\/volumes","created_at":"2026-01-02T03:04:05+00:00","updated_at":"2026-02-03T04:05:06+00:00","allocated_resources":{"memory":3072,"disk":15360},"relationships":{"tags":{"object":"null_resource","attributes":null},"deployment_tags":{"object":"null_resource","attributes":null}},"extensions":{}}} diff --git a/tests/Fixtures/openapi/baseline.yaml b/tests/Fixtures/openapi/baseline.yaml index 63966474d..25176f0d8 100644 --- a/tests/Fixtures/openapi/baseline.yaml +++ b/tests/Fixtures/openapi/baseline.yaml @@ -1193,6 +1193,18 @@ components: $ref: '#/components/schemas/AdminLocationResource' - $ref: '#/components/schemas/NullResource' + tags: + oneOf: + - + $ref: '#/components/schemas/AdminTagListResponse' + - + $ref: '#/components/schemas/NullResource' + deployment_tags: + oneOf: + - + $ref: '#/components/schemas/AdminTagListResponse' + - + $ref: '#/components/schemas/NullResource' AdminNodeConfigurationResponse: type: object required: @@ -7275,22 +7287,28 @@ components: description: 'Results to return per page.' AdminListNodesIncludeQueryParameter: type: string - description: 'Comma-separated relationships to include. Supports "allocations", "location", and "servers".' + description: 'Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations).' enum: - allocations - location - servers - 'allocations,location' - 'location,servers' + - tags + - deployment_tags + - 'tags,deployment_tags' AdminGetNodeIncludeQueryParameter: type: string - description: 'Comma-separated relationships to include. Supports "allocations", "location", and "servers".' + description: 'Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations).' enum: - allocations - location - servers - 'allocations,location' - 'location,servers' + - tags + - deployment_tags + - 'tags,deployment_tags' AdminGetNodeNodeIdPathParameter: type: integer AdminGetNodeConfigurationNodeIdPathParameter: @@ -7635,12 +7653,15 @@ components: - '-disk' ApplicationListNodesIncludeQueryParameter: type: string - description: 'Comma-separated relationships to include. Supports "allocations", "location", and "servers" when the key can read those resources.' + description: 'Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations) when the key can read those resources. The tags need read access to eggs.' enum: - allocations - location - servers - 'location,allocations' + - tags + - deployment_tags + - 'tags,deployment_tags' ApplicationListDeployableNodesMemoryQueryParameter: type: integer description: 'Memory required for the deployment, in megabytes.' @@ -7660,12 +7681,15 @@ components: description: 'Number of nodes to return per page when page is supplied, up to 100.' ApplicationGetNodeIncludeQueryParameter: type: string - description: 'Comma-separated relationships to include. Supports "allocations", "location", and "servers" when the key can read those resources.' + description: 'Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations) when the key can read those resources. The tags need read access to eggs.' enum: - allocations - location - servers - 'location,allocations' + - tags + - deployment_tags + - 'tags,deployment_tags' ApplicationGetNodeNodeIdPathParameter: type: integer ApplicationGetNodeConfigurationNodeIdPathParameter: @@ -10448,7 +10472,7 @@ paths: - in: query name: include - description: 'Comma-separated relationships to include. Supports "allocations", "location", and "servers".' + description: 'Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations).' required: false schema: $ref: '#/components/schemas/AdminListNodesIncludeQueryParameter' @@ -10520,7 +10544,7 @@ paths: - in: query name: include - description: 'Comma-separated relationships to include. Supports "allocations", "location", and "servers".' + description: 'Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations).' required: false schema: $ref: '#/components/schemas/AdminGetNodeIncludeQueryParameter' @@ -14018,7 +14042,7 @@ paths: - in: query name: include - description: 'Comma-separated relationships to include. Supports "allocations", "location", and "servers" when the key can read those resources.' + description: 'Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations) when the key can read those resources. The tags need read access to eggs.' required: false schema: $ref: '#/components/schemas/ApplicationListNodesIncludeQueryParameter' @@ -14164,7 +14188,7 @@ paths: - in: query name: include - description: 'Comma-separated relationships to include. Supports "allocations", "location", and "servers" when the key can read those resources.' + description: 'Comma-separated relationships to include. Supports "allocations", "location", "servers", "tags" (the games the node accepts), and "deployment_tags" (its reservations) when the key can read those resources. The tags need read access to eggs.' required: false schema: $ref: '#/components/schemas/ApplicationGetNodeIncludeQueryParameter' diff --git a/tests/Integration/Api/Snapshots/AdminResponseSnapshotTest.php b/tests/Integration/Api/Snapshots/AdminResponseSnapshotTest.php index 75ba95518..d5a31cc5e 100644 --- a/tests/Integration/Api/Snapshots/AdminResponseSnapshotTest.php +++ b/tests/Integration/Api/Snapshots/AdminResponseSnapshotTest.php @@ -114,6 +114,11 @@ function adminReads(): array 'mounts view' => [['requests' => [...adminMatrix('mount', ADMIN.'/mounts/1'), ['GET', ADMIN.'/mounts/2?include=eggs,nodes,servers']]]], 'nodes index' => [['requests' => [...adminMatrix('node', ADMIN.'/nodes'), ...World::pages(ADMIN.'/nodes', ADMIN.'/nodes?filter[name]=none')]]], 'nodes view' => [['requests' => [...adminMatrix('node', ADMIN.'/nodes/1'), ['GET', ADMIN.'/nodes/2?include=allocations,location,servers']]]], + 'nodes tags' => [['requests' => [ + ['GET', ADMIN.'/nodes?include=tags,deployment_tags'], + ['GET', ADMIN.'/nodes/1?include=tags'], + ['GET', ADMIN.'/nodes/2?include=deployment_tags.nodes'], + ]]], 'nodes allocations' => [['requests' => [ ...adminMatrix('allocation', ADMIN.'/nodes/1/allocations'), ...World::pages(ADMIN.'/nodes/1/allocations', ADMIN.'/nodes/1/allocations?filter[ip]=203.0.113.250'), diff --git a/tests/Integration/Api/Snapshots/ApplicationResponseSnapshotTest.php b/tests/Integration/Api/Snapshots/ApplicationResponseSnapshotTest.php index 492f5ed22..803369751 100644 --- a/tests/Integration/Api/Snapshots/ApplicationResponseSnapshotTest.php +++ b/tests/Integration/Api/Snapshots/ApplicationResponseSnapshotTest.php @@ -101,6 +101,14 @@ function applicationReads(): array ['GET', APP.'/nodes/deployable?memory=128&disk=128&location_ids[]=1&page=1&per_page=1&include=location'], ]]], 'nodes view' => [['requests' => [...applicationMatrix('node', APP.'/nodes/1'), ['GET', APP.'/nodes/2?include=allocations,location,servers']]]], + 'nodes tags' => [['requests' => [ + ['GET', APP.'/nodes?include=tags,deployment_tags'], + ['GET', APP.'/nodes/1?include=tags'], + ['GET', APP.'/nodes/2?include=deployment_tags.nodes'], + ]]], + 'nodes tags without eggs access' => [['key' => [AdminAcl::COLUMN_IDENTIFIER.AdminAcl::RESOURCE_EGGS => AdminAcl::NONE], 'requests' => [ + ['GET', APP.'/nodes/1?include=tags,deployment_tags'], + ]]], 'nodes allocations' => [['requests' => [ ...applicationMatrix('allocation', APP.'/nodes/1/allocations'), ...World::pages(APP.'/nodes/1/allocations', APP.'/nodes/1/allocations?filter[ip]=203.0.113.250'),