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; |
13
|
|
|
|
14
|
|
|
use Linode\Entity; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* A keypair used to communicate with the Object Storage S3 API. |
18
|
|
|
* |
19
|
|
|
* @property int $id This keypair's unique ID |
20
|
|
|
* @property string $label The label given to this key. For display purposes only. |
21
|
|
|
* @property string $access_key This keypair's access key. This is not secret. |
22
|
|
|
* @property string $secret_key This keypair's secret key. Only returned on key creation. |
23
|
|
|
* @property bool $limited Whether or not this key is a limited access key. Will return `false` if this key |
24
|
|
|
* grants full access to all buckets on the user's account. |
25
|
|
|
* @property LimitedAccessKey[] $bucket_access Defines this key as a Limited Access Key. Limited Access Keys restrict this Object |
26
|
|
|
* Storage key's access to only the bucket(s) declared in this array and define their |
27
|
|
|
* bucket-level permissions. |
28
|
|
|
* Limited Access Keys can: |
29
|
|
|
* * list all buckets available on this Account, but cannot perform any actions on |
30
|
|
|
* a bucket unless it has access to the bucket. |
31
|
|
|
* * create new buckets, but do not have any access to the buckets it creates, |
32
|
|
|
* unless explicitly given access to them. |
33
|
|
|
* **Note:** You can create an Object Storage Limited Access Key without access to |
34
|
|
|
* any buckets. |
35
|
|
|
* This is achieved by sending a request with an empty `bucket_access` array. |
36
|
|
|
* **Note:** If this field is omitted, a regular unlimited access key is issued. |
37
|
|
|
*/ |
38
|
|
|
class ObjectStorageKey extends Entity |
39
|
|
|
{ |
40
|
|
|
// Available fields. |
41
|
|
|
public const FIELD_ID = 'id'; |
42
|
|
|
public const FIELD_LABEL = 'label'; |
43
|
|
|
public const FIELD_ACCESS_KEY = 'access_key'; |
44
|
|
|
public const FIELD_SECRET_KEY = 'secret_key'; |
45
|
|
|
public const FIELD_LIMITED = 'limited'; |
46
|
|
|
public const FIELD_BUCKET_ACCESS = 'bucket_access'; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @codeCoverageIgnore This method was autogenerated. |
50
|
|
|
*/ |
51
|
|
|
public function __get(string $name): mixed |
52
|
|
|
{ |
53
|
|
|
return match ($name) { |
54
|
|
|
self::FIELD_BUCKET_ACCESS => array_map(fn ($data) => new LimitedAccessKey($this->client, $data), $this->data[$name]), |
55
|
|
|
default => parent::__get($name), |
56
|
|
|
}; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|