-
Notifications
You must be signed in to change notification settings - Fork 158
Expand file tree
/
Copy pathUser.php
More file actions
106 lines (85 loc) · 2.39 KB
/
User.php
File metadata and controls
106 lines (85 loc) · 2.39 KB
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
<?php
declare(strict_types=1);
namespace OpenStack\Identity\v3\Models;
use OpenStack\Common\Resource\Creatable;
use OpenStack\Common\Resource\Deletable;
use OpenStack\Common\Resource\Listable;
use OpenStack\Common\Resource\OperatorResource;
use OpenStack\Common\Resource\Retrievable;
use OpenStack\Common\Resource\Updateable;
/**
* @property \OpenStack\Identity\v3\Api $api
*/
class User extends OperatorResource implements Creatable, Listable, Retrievable, Updateable, Deletable
{
/** @var string */
public $domainId;
/** @var string */
public $defaultProjectId;
/** @var string */
public $id;
/** @var string */
public $email;
/** @var bool */
public $enabled;
/** @var string */
public $description;
/** @var array */
public $links;
/** @var string */
public $name;
protected $aliases = [
'domain_id' => 'domainId',
'default_project_id' => 'defaultProjectId',
];
protected $resourceKey = 'user';
protected $resourcesKey = 'users';
/**
* {@inheritdoc}
*
* @param array $data {@see \OpenStack\Identity\v3\Api::postUsers}
*/
public function create(array $data): Creatable
{
$response = $this->execute($this->api->postUsers(), $data);
return $this->populateFromResponse($response);
}
/**
* {@inheritdoc}
*/
public function retrieve()
{
$response = $this->execute($this->api->getUser(), ['id' => $this->id]);
$this->populateFromResponse($response);
}
/**
* {@inheritdoc}
*/
public function update()
{
$response = $this->executeWithState($this->api->patchUser());
$this->populateFromResponse($response);
}
/**
* {@inheritdoc}
*/
public function delete()
{
$this->execute($this->api->deleteUser(), ['id' => $this->id]);
}
/**
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\Group>
*/
public function listGroups(): \Generator
{
$options['id'] = $this->id;
return $this->model(Group::class)->enumerate($this->api->getUserGroups(), $options);
}
/**
* @return \Generator<mixed, \OpenStack\Identity\v3\Models\Project>
*/
public function listProjects(): \Generator
{
return $this->model(Project::class)->enumerate($this->api->getUserProjects(), ['id' => $this->id]);
}
}