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/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(