|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace OpenStack\Images\v2\Models; |
|
4
|
|
|
|
|
5
|
|
|
use OpenStack\Common\Resource\Alias; |
|
6
|
|
|
use OpenStack\Common\Resource\OperatorResource; |
|
7
|
|
|
use OpenStack\Common\Resource\Creatable; |
|
8
|
|
|
use OpenStack\Common\Resource\Deletable; |
|
9
|
|
|
use OpenStack\Common\Resource\Listable; |
|
10
|
|
|
use OpenStack\Common\Resource\Retrievable; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @property \OpenStack\Images\v2\Api $api |
|
14
|
|
|
*/ |
|
15
|
|
|
class Member extends OperatorResource implements Creatable, Listable, Retrievable, Deletable |
|
16
|
|
|
{ |
|
17
|
|
|
const STATUS_ACCEPTED = 'accepted'; |
|
18
|
|
|
const STATUS_PENDING = 'pending'; |
|
19
|
|
|
const STATUS_REJECTED = 'rejected'; |
|
20
|
|
|
|
|
21
|
|
|
/** @var string */ |
|
22
|
|
|
public $imageId; |
|
23
|
|
|
|
|
24
|
|
|
/** @var string */ |
|
25
|
|
|
public $id; |
|
26
|
|
|
|
|
27
|
|
|
/** @var \DateTimeImmutable */ |
|
28
|
|
|
public $createdAt; |
|
29
|
|
|
|
|
30
|
|
|
/** @var \DateTimeImmutable */ |
|
31
|
|
|
public $updatedAt; |
|
32
|
|
|
|
|
33
|
|
|
/** @var string */ |
|
34
|
|
|
public $schemaUri; |
|
35
|
|
|
|
|
36
|
|
|
/** @var string */ |
|
37
|
|
|
public $status; |
|
38
|
|
|
|
|
39
|
|
|
protected $aliases = [ |
|
40
|
|
|
'member_id' => 'id', |
|
41
|
|
|
'image_id' => 'imageId', |
|
42
|
|
|
]; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @inheritdoc |
|
46
|
1 |
|
*/ |
|
47
|
|
|
protected function getAliases(): array |
|
48
|
1 |
|
{ |
|
49
|
1 |
|
return parent::getAliases() + [ |
|
50
|
|
|
'created_at' => new Alias('createdAt', \DateTimeImmutable::class), |
|
51
|
|
|
'updated_at' => new Alias('updatedAt', \DateTimeImmutable::class) |
|
52
|
1 |
|
]; |
|
53
|
|
|
} |
|
54
|
1 |
|
|
|
55
|
1 |
|
public function create(array $userOptions): Creatable |
|
56
|
1 |
|
{ |
|
57
|
|
|
$response = $this->executeWithState($this->api->postImageMembers()); |
|
58
|
1 |
|
return $this->populateFromResponse($response); |
|
59
|
|
|
} |
|
60
|
1 |
|
|
|
61
|
1 |
|
public function retrieve() |
|
62
|
|
|
{ |
|
63
|
1 |
|
$response = $this->executeWithState($this->api->getImageMember()); |
|
64
|
|
|
$this->populateFromResponse($response); |
|
65
|
1 |
|
} |
|
66
|
1 |
|
|
|
67
|
1 |
|
public function delete() |
|
68
|
|
|
{ |
|
69
|
|
|
$this->executeWithState($this->api->deleteImageMember()); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function updateStatus($status) |
|
73
|
|
|
{ |
|
74
|
|
|
$this->status = $status; |
|
75
|
|
|
$this->executeWithState($this->api->putImageMember()); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|