update resources

Signed-off-by: Maurice Preuß (envoyr) <hello@envoyr.com>
This commit is contained in:
2025-05-02 06:27:53 +02:00
parent 1725ec68de
commit 1d2119a32b
33 changed files with 303 additions and 320 deletions

View File

@@ -3,9 +3,8 @@
namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\HasParent;
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
use Anikeen\Id\Result;
use GuzzleHttp\Exception\GuzzleException;
use Throwable;
class SshKeys extends BaseCollection
{
@@ -16,12 +15,11 @@ class SshKeys extends BaseCollection
*
* @param string $publicKey The public key to be added
* @param string|null $name The name of the key (optional)
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function create(string $publicKey, ?string $name = null): SshKey
{
return (new SshKey($this->parent->post('v1/ssh-keys', [
return (new SshKey(fn() => $this->parent->post('v1/ssh-keys', [
'public_key' => $publicKey,
'name' => $name,
])))->setParent($this->parent);
@@ -32,12 +30,6 @@ class SshKeys extends BaseCollection
*/
public function find(string $id): ?SshKey
{
/** @var Result $result */
$result = $this->parent->get(sprintf('v1/ssh-keys/%s', $id));
return $result->success()
? (new SshKey($result))
->setParent($this->parent)
: null;
return (new SshKey(fn() => $this->parent->get(sprintf('v1/ssh-keys/%s', $id))));
}
}