|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
// --------------------------------------------------------------------- |
|
4
|
|
|
// |
|
5
|
|
|
// Copyright (C) 2018-2024 Artem Rodygin |
|
6
|
|
|
// |
|
7
|
|
|
// You should have received a copy of the MIT License along with |
|
8
|
|
|
// this file. If not, see <https://opensource.org/licenses/MIT>. |
|
9
|
|
|
// |
|
10
|
|
|
// --------------------------------------------------------------------- |
|
11
|
|
|
|
|
12
|
|
|
namespace Linode\ObjectStorage\Repository; |
|
13
|
|
|
|
|
14
|
|
|
use Linode\Entity; |
|
15
|
|
|
use Linode\Internal\AbstractRepository; |
|
16
|
|
|
use Linode\ObjectStorage\ObjectStorageKey; |
|
17
|
|
|
use Linode\ObjectStorage\ObjectStorageKeyRepositoryInterface; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @codeCoverageIgnore This class was autogenerated. |
|
21
|
|
|
*/ |
|
22
|
|
|
class ObjectStorageKeyRepository extends AbstractRepository implements ObjectStorageKeyRepositoryInterface |
|
23
|
|
|
{ |
|
24
|
|
|
public function createObjectStorageKeys(array $parameters = []): ObjectStorageKey |
|
25
|
|
|
{ |
|
26
|
|
|
$response = $this->client->post($this->getBaseUri(), $parameters); |
|
27
|
|
|
$contents = $response->getBody()->getContents(); |
|
28
|
|
|
$json = json_decode($contents, true); |
|
29
|
|
|
|
|
30
|
|
|
return new ObjectStorageKey($this->client, $json); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function updateObjectStorageKey(int $keyId, array $parameters = []): ObjectStorageKey |
|
34
|
|
|
{ |
|
35
|
|
|
$response = $this->client->put(sprintf('%s/%s', $this->getBaseUri(), $keyId), $parameters); |
|
36
|
|
|
$contents = $response->getBody()->getContents(); |
|
37
|
|
|
$json = json_decode($contents, true); |
|
38
|
|
|
|
|
39
|
|
|
return new ObjectStorageKey($this->client, $json); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function deleteObjectStorageKey(int $keyId): void |
|
43
|
|
|
{ |
|
44
|
|
|
$this->client->delete(sprintf('%s/%s', $this->getBaseUri(), $keyId)); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
protected function getBaseUri(): string |
|
48
|
|
|
{ |
|
49
|
|
|
return 'beta/object-storage/keys'; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
protected function getSupportedFields(): array |
|
53
|
|
|
{ |
|
54
|
|
|
return [ |
|
55
|
|
|
ObjectStorageKey::FIELD_ID, |
|
56
|
|
|
ObjectStorageKey::FIELD_LABEL, |
|
57
|
|
|
ObjectStorageKey::FIELD_ACCESS_KEY, |
|
58
|
|
|
ObjectStorageKey::FIELD_SECRET_KEY, |
|
59
|
|
|
]; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
protected function jsonToEntity(array $json): Entity |
|
63
|
|
|
{ |
|
64
|
|
|
return new ObjectStorageKey($this->client, $json); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|