From e8c33c89f9806f928920d7c800ff707676ef8cb2 Mon Sep 17 00:00:00 2001 From: Vincent Bergeron Date: Thu, 25 Sep 2025 19:58:00 -0400 Subject: [PATCH 1/2] Add restartRedis --- README.md | 6 ++++++ src/Endpoints/Server.php | 7 +++++++ src/Resources/Server.php | 5 +++++ src/SpinupWp.php | 2 +- tests/Endpoints/ServerTest.php | 9 +++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f2cb011..21383fc 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,9 @@ $eventId = $spinupwp->servers->reboot($serverId); // Restart the Nginx service on a server $eventId = $spinupwp->servers->restartNginx($serverId); +// Restart the Redis service on a server +$eventId = $spinupwp->servers->restartRedis($serverId); + // Restart all versions of the PHP-FPM service installed on a server $eventId = $spinupwp->servers->restartPhp($serverId); @@ -62,6 +65,9 @@ $server->reboot(); // Restart the Nginx service on the current server $server->restartNginx(); +// Restart the Redis service on the current server +$server->restartRedis(); + // Restart all versions of the PHP-FPM service installed on the current server $server->restartPhp(); diff --git a/src/Endpoints/Server.php b/src/Endpoints/Server.php index 18ee6c0..ee8dd5f 100644 --- a/src/Endpoints/Server.php +++ b/src/Endpoints/Server.php @@ -60,6 +60,13 @@ public function restartNginx(int $id): int return $request['event_id']; } + public function restartRedis(int $id): int + { + $request = $this->postRequest("servers/{$id}/services/redis/restart"); + + return $request['event_id']; + } + public function restartPhp(int $id): int { $request = $this->postRequest("servers/{$id}/services/php/restart"); diff --git a/src/Resources/Server.php b/src/Resources/Server.php index 3e036ab..00f0672 100644 --- a/src/Resources/Server.php +++ b/src/Resources/Server.php @@ -24,6 +24,11 @@ public function restartNginx(): int return $this->spinupwp->servers->restartNginx($this->id); } + public function restartRedis(): int + { + return $this->spinupwp->servers->restartRedis($this->id); + } + public function restartPhp(): int { return $this->spinupwp->servers->restartPhp($this->id); diff --git a/src/SpinupWp.php b/src/SpinupWp.php index 7ea7484..f28b580 100644 --- a/src/SpinupWp.php +++ b/src/SpinupWp.php @@ -16,7 +16,7 @@ */ class SpinupWp { - public const API_URL = 'https://api.spinupwp.app/v1/'; + public const API_URL = 'https://api.spinupwp.test/v1/'; protected string $apiKey; diff --git a/tests/Endpoints/ServerTest.php b/tests/Endpoints/ServerTest.php index 1e58751..a389e38 100644 --- a/tests/Endpoints/ServerTest.php +++ b/tests/Endpoints/ServerTest.php @@ -118,6 +118,15 @@ public function test_restart_nginx(): void $this->assertEquals(100, $this->serverEndpoint->restartNginx(1)); } + public function test_restart_redis(): void + { + $this->client->shouldReceive('request')->once()->with('POST', 'servers/1/services/redis/restart', [])->andReturn( + new Response(200, [], '{"event_id": 100}') + ); + + $this->assertEquals(100, $this->serverEndpoint->restartRedis(1)); + } + public function test_restart_php(): void { $this->client->shouldReceive('request')->once()->with('POST', 'servers/1/services/php/restart', [])->andReturn( From 839d543ed1a2c81a1c6e2615d1342ef3c388324a Mon Sep 17 00:00:00 2001 From: Vincent Bergeron Date: Thu, 25 Sep 2025 20:07:26 -0400 Subject: [PATCH 2/2] Fix url --- src/SpinupWp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SpinupWp.php b/src/SpinupWp.php index f28b580..7ea7484 100644 --- a/src/SpinupWp.php +++ b/src/SpinupWp.php @@ -16,7 +16,7 @@ */ class SpinupWp { - public const API_URL = 'https://api.spinupwp.test/v1/'; + public const API_URL = 'https://api.spinupwp.app/v1/'; protected string $apiKey;