1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace OpenStack\Networking\v2\Extensions\SecurityGroups\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
|
|
|
use OpenStack\Common\Resource\Updateable; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Represents a SecurityGroup resource in the Network v2 service |
15
|
|
|
* |
16
|
|
|
* @property \OpenStack\Networking\v2\Extensions\SecurityGroups\Api $api |
17
|
|
|
*/ |
18
|
|
|
class SecurityGroup extends OperatorResource implements Creatable, Listable, Deletable, Retrievable, Updateable |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
public $description; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
public $id; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
public $name; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var []SecurityGroupRule |
37
|
|
|
*/ |
38
|
|
|
public $securityGroupRules; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
public $tenantId; |
44
|
|
|
|
45
|
|
|
protected $aliases = [ |
46
|
|
|
'tenant_id' => 'tenantId', |
47
|
|
|
]; |
48
|
|
|
|
49
|
|
|
protected $resourceKey = 'security_group'; |
50
|
|
|
protected $resourcesKey = 'security_groups'; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @inheritdoc |
54
|
|
|
*/ |
55
|
|
|
protected function getAliases(): array |
56
|
|
|
{ |
57
|
|
|
return parent::getAliases() + [ |
58
|
|
|
'security_group_rules' => new Alias('securityGroupRules', SecurityGroupRule::class, true), |
59
|
|
|
'rules' => new Alias('securityGroupRules', SecurityGroupRule::class, true) |
60
|
|
|
]; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* {@inheritDoc} |
65
|
|
|
*/ |
66
|
|
|
public function create(array $userOptions): Creatable |
67
|
|
|
{ |
68
|
|
|
$response = $this->execute($this->api->postSecurityGroups(), $userOptions); |
69
|
|
|
return $this->populateFromResponse($response); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* {@inheritDoc} |
74
|
|
|
*/ |
75
|
|
|
public function delete() |
76
|
|
|
{ |
77
|
|
|
$this->executeWithState($this->api->deleteSecurityGroup()); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* {@inheritDoc} |
82
|
|
|
*/ |
83
|
|
|
public function retrieve() |
84
|
|
|
{ |
85
|
|
|
$response = $this->executeWithState($this->api->getSecurityGroup()); |
86
|
|
|
$this->populateFromResponse($response); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function update() |
90
|
|
|
{ |
91
|
|
|
$response = $this->executeWithState($this->api->putSecurityGroups()); |
92
|
|
|
$this->populateFromResponse($response); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|