Skip to content

Commit aa847a6

Browse files
committed
added endpoint
1 parent e3bf211 commit aa847a6

File tree

5 files changed

+69
-0
lines changed

5 files changed

+69
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,21 @@ $updatedStream = $vanguard->updateNotificationStream($streamId, [
236236
$vanguard->deleteNotificationStream($streamId);
237237
```
238238

239+
### SSH Key Management
240+
241+
Retrieve the Vanguard instance SSH public key:
242+
243+
```php
244+
// Get the instance SSH public key
245+
$sshKey = $vanguard->getInstanceSshKey();
246+
247+
// Access the public key as a string
248+
echo $sshKey->publicKey;
249+
250+
// Or cast the object to a string to get the public key
251+
echo (string) $sshKey;
252+
```
253+
239254
## Security
240255

241256
For reporting security vulnerabilities, please refer to our [security policy](https://github.com/vanguardbackup/vanguard/security/policy).

src/Actions/ManagesSshKeys.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace VanguardBackup\Vanguard\Actions;
6+
7+
use VanguardBackup\Vanguard\Resources\SshKey;
8+
9+
trait ManagesSshKeys
10+
{
11+
/**
12+
* Get the Vanguard instance SSH public key.
13+
*
14+
* This key can be used for SSH authentication when connecting to remote servers.
15+
*/
16+
public function getInstanceSshKey(): SshKey
17+
{
18+
return new SshKey($this->get('ssh-key'), $this);
19+
}
20+
}

src/Facades/Vanguard.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66

77
use Illuminate\Support\Facades\Facade;
88
use VanguardBackup\Vanguard\Resources\ScheduledBackupTask;
9+
use VanguardBackup\Vanguard\Resources\SshKey;
910
use VanguardBackup\Vanguard\VanguardManager;
1011

1112
/**
1213
* @method static \VanguardBackup\Vanguard\VanguardClient setApiKey(string $apiKey, \GuzzleHttp\Client|null $httpClient = null)
1314
* @method static \VanguardBackup\Vanguard\VanguardClient setBaseUrl(string $url)
1415
* @method static string getBaseUrl()
1516
* @method static \VanguardBackup\Vanguard\Resources\User user()
17+
* @method static SshKey getInstanceSshKey()
1618
* @method static \VanguardBackup\Vanguard\Resources\Tag[] tags()
1719
* @method static \VanguardBackup\Vanguard\Resources\Tag tag(string $tagId)
1820
* @method static \VanguardBackup\Vanguard\Resources\Tag createTag(array $data)

src/Resources/SshKey.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace VanguardBackup\Vanguard\Resources;
6+
7+
class SshKey extends Resource
8+
{
9+
/**
10+
* The SSH public key.
11+
*/
12+
public string $publicKey;
13+
14+
/**
15+
* Create a new resource instance.
16+
*/
17+
public function __construct(array $attributes, $vanguard = null)
18+
{
19+
parent::__construct($attributes, $vanguard);
20+
21+
$this->publicKey = $attributes['public_key'];
22+
}
23+
24+
/**
25+
* Get the string representation of the SSH key.
26+
*/
27+
public function __toString(): string
28+
{
29+
return $this->publicKey;
30+
}
31+
}

src/VanguardClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class VanguardClient
1414
Actions\ManagesBackupTasks,
1515
Actions\ManagesNotificationStreams,
1616
Actions\ManagesRemoteServers,
17+
Actions\ManagesSshKeys,
1718
Actions\ManagesTags,
1819
MakesHttpRequests,
1920
ManagesBackupTaskLogs;

0 commit comments

Comments
 (0)