-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathUserCapability.php
112 lines (98 loc) · 2.28 KB
/
UserCapability.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php declare(strict_types=1);
namespace MyENA\RGW\Models;
use MyENA\RGW\AbstractModel;
use OpenApi\Annotations as OA;
/**
* @OA\Schema(
* schema="RGWUserCapability",
* type="object",
* @OA\Property(
* property="type",
* type="string"
* ),
* @OA\Property(
* property="perm",
* type="string"
* )
* )
*/
/**
* Class UserCapability
* @package MyENA\RGW\Models
*/
class UserCapability extends AbstractModel
{
public const KEY_TYPE = 'type';
public const KEY_PERM = 'perm';
public const TYPE_USERS = 'users';
public const TYPE_BUCKETS = 'buckets';
public const TYPE_METADATA = 'metadata';
public const TYPE_USAGE = 'usage';
public const TYPE_ZONE = 'zone';
public const PERM_ALL = '*';
public const PERM_READ = 'read';
public const PERM_WRITE = 'write';
public const PERM_READ_WRITE = 'read,write';
/** @var string */
protected $type;
/** @var string */
protected $permission;
/**
* UserCapability constructor.
* @param array $data
*/
public function __construct(array $data = [])
{
$this->type = $data['type'] ?? '';
if (isset($data['permission'])) {
$this->permission = $data['permission'];
} elseif (isset($data['perm'])) {
$this->permission = $data['perm'];
}
}
/**
* @return string
*/
public function __toString()
{
return "{$this->getType()}={$this->getPermission()}";
}
/**
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* @param string $type
*/
public function setType(string $type): void
{
$this->type = $type;
}
/**
* @return string
*/
public function getPermission(): string
{
return $this->permission ?? '';
}
/**
* @param string $permission
*/
public function setPermission(string $permission): void
{
$this->permission = $permission;
}
/**
* @return array
*/
public function jsonSerialize()
{
return [
self::KEY_TYPE => $this->getType(),
self::KEY_PERM => $this->getPermission(),
];
}
}