SshKeys::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 12
rs 10
1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Response\OperationResponse;
6
use AcquiaCloudApi\Response\SshKeyResponse;
7
use AcquiaCloudApi\Response\SshKeysResponse;
8
9
/**
10
 * Class SshKeys
11
 *
12
 * @package AcquiaCloudApi\CloudApi
13
 */
14
class SshKeys extends CloudApiBase
15
{
16
    /**
17
     * Returns a list of SSL keys.
18
     *
19
     * @return SshKeysResponse<SshKeyResponse>
20
     */
21
    public function getAll(): SshKeysResponse
22
    {
23
        return new SshKeysResponse(
24
            $this->client->request(
25
                'get',
26
                "/account/ssh-keys"
27
            )
28
        );
29
    }
30
31
    /**
32
     * Returns a specific key by key ID.
33
     */
34
    public function get(string $keyId): SshKeyResponse
35
    {
36
        return new SshKeyResponse(
37
            $this->client->request(
38
                'get',
39
                "/account/ssh-keys/$keyId"
40
            )
41
        );
42
    }
43
44
    /**
45
     * Create an SSH key.
46
     */
47
    public function create(string $label, string $public_key): OperationResponse
48
    {
49
50
        $options = [
51
            'json' => [
52
                'label' => $label,
53
                'public_key' => $public_key,
54
            ],
55
        ];
56
57
        return new OperationResponse(
58
            $this->client->request('post', "/account/ssh-keys", $options)
59
        );
60
    }
61
62
    /**
63
     * Delete a specific key by ID.
64
     */
65
    public function delete(string $keyId): OperationResponse
66
    {
67
        return new OperationResponse(
68
            $this->client->request('delete', "/account/ssh-keys/$keyId")
69
        );
70
    }
71
}
72