1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace OpenStack\Identity\v3\Models; |
4
|
|
|
|
5
|
|
|
use OpenStack\Common\Resource\OperatorResource; |
6
|
|
|
use OpenStack\Common\Resource\Creatable; |
7
|
|
|
use OpenStack\Common\Resource\Deletable; |
8
|
|
|
use OpenStack\Common\Resource\Updateable; |
9
|
|
|
use OpenStack\Common\Resource\Retrievable; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @property \OpenStack\Identity\v3\Api $api |
13
|
|
|
*/ |
14
|
|
|
class Endpoint extends OperatorResource implements Creatable, Updateable, Deletable, Retrievable |
15
|
|
|
{ |
16
|
|
|
/** @var string */ |
17
|
|
|
public $id; |
18
|
|
|
|
19
|
|
|
/** @var string */ |
20
|
|
|
public $interface; |
21
|
|
|
|
22
|
|
|
/** @var string */ |
23
|
|
|
public $name; |
24
|
|
|
|
25
|
|
|
/** @var string */ |
26
|
|
|
public $serviceId; |
27
|
|
|
|
28
|
|
|
/** @var string */ |
29
|
|
|
public $region; |
30
|
|
|
|
31
|
|
|
/** @var array */ |
32
|
|
|
public $links; |
33
|
|
|
|
34
|
|
|
/** @var string */ |
35
|
|
|
public $url; |
36
|
|
|
|
37
|
|
|
protected $resourceKey = 'endpoint'; |
38
|
|
|
protected $resourcesKey = 'endpoints'; |
39
|
|
|
protected $aliases = ['service_id' => 'serviceId']; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritDoc} |
43
|
|
|
* |
44
|
|
|
* @param array $data {@see \OpenStack\Identity\v3\Api::postEndpoints} |
45
|
2 |
|
*/ |
46
|
|
|
public function create(array $data): Creatable |
47
|
2 |
|
{ |
48
|
2 |
|
$response = $this->execute($this->api->postEndpoints(), $data); |
49
|
|
|
return $this->populateFromResponse($response); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* {@inheritDoc} |
54
|
1 |
|
*/ |
55
|
|
|
public function retrieve() |
56
|
1 |
|
{ |
57
|
1 |
|
$response = $this->executeWithState($this->api->getEndpoint()); |
58
|
|
|
$this->populateFromResponse($response); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* {@inheritDoc} |
63
|
1 |
|
*/ |
64
|
|
|
public function update() |
65
|
1 |
|
{ |
66
|
1 |
|
$response = $this->executeWithState($this->api->patchEndpoint()); |
67
|
|
|
$this->populateFromResponse($response); |
68
|
2 |
|
} |
69
|
|
|
|
70
|
2 |
|
/** |
71
|
|
|
* {@inheritDoc} |
72
|
|
|
*/ |
73
|
2 |
|
public function delete() |
74
|
|
|
{ |
75
|
2 |
|
$this->execute($this->api->deleteEndpoint(), $this->getAttrs(['id'])); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function regionMatches(string $value): bool |
79
|
|
|
{ |
80
|
|
|
return $this->region && $this->region == $value; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function interfaceMatches(string $value): bool |
84
|
|
|
{ |
85
|
|
|
return $this->interface && $this->interface == $value; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|