1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace OpenStack\Networking\v2\Models; |
4
|
|
|
|
5
|
|
|
use OpenStack\Common\Resource\OperatorResource; |
6
|
|
|
use OpenStack\Common\Resource\HasWaiterTrait; |
7
|
|
|
use OpenStack\Common\Resource\Listable; |
8
|
|
|
use OpenStack\Common\Resource\Creatable; |
9
|
|
|
use OpenStack\Common\Resource\Deletable; |
10
|
|
|
use OpenStack\Common\Resource\Retrievable; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Represents a Networking v2 Network. |
14
|
|
|
* |
15
|
|
|
* @property \OpenStack\Networking\v2\Api $api |
16
|
|
|
*/ |
17
|
|
|
class Network extends OperatorResource implements Listable, Retrievable, Creatable, Deletable |
18
|
|
|
{ |
19
|
|
|
use HasWaiterTrait; |
20
|
|
|
|
21
|
|
|
/** @var string */ |
22
|
|
|
public $id; |
23
|
|
|
|
24
|
|
|
/** @var string */ |
25
|
|
|
public $name; |
26
|
|
|
|
27
|
|
|
/** @var bool */ |
28
|
|
|
public $shared; |
29
|
|
|
|
30
|
|
|
/** @var string */ |
31
|
|
|
public $status; |
32
|
|
|
|
33
|
|
|
/** @var array */ |
34
|
|
|
public $subnets; |
35
|
|
|
|
36
|
|
|
/** @var string */ |
37
|
|
|
public $adminStateUp; |
38
|
|
|
|
39
|
|
|
/** @var string */ |
40
|
|
|
public $tenantId; |
41
|
|
|
|
42
|
|
|
protected $aliases = [ |
43
|
|
|
'admin_state_up' => 'adminStateUp', |
44
|
|
|
'tenant_id' => 'tenantId', |
45
|
|
|
]; |
46
|
|
|
|
47
|
1 |
|
protected $resourceKey = 'network'; |
48
|
|
|
protected $resourcesKey = 'networks'; |
49
|
1 |
|
|
50
|
1 |
|
/** |
51
|
1 |
|
* {@inheritDoc} |
52
|
|
|
*/ |
53
|
|
|
public function retrieve() |
54
|
|
|
{ |
55
|
|
|
$response = $this->execute($this->api->getNetwork(), ['id' => (string)$this->id]); |
56
|
|
|
$this->populateFromResponse($response); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
2 |
|
* Creates multiple networks in a single request. |
61
|
|
|
* |
62
|
2 |
|
* @param array $data {@see \OpenStack\Networking\v2\Api::postNetworks} |
63
|
2 |
|
* |
64
|
|
|
* @return Network[] |
65
|
|
|
*/ |
66
|
|
|
public function bulkCreate(array $data): array |
67
|
|
|
{ |
68
|
|
|
$response = $this->execute($this->api->postNetworks(), ['networks' => $data]); |
69
|
|
|
return $this->extractMultipleInstances($response); |
70
|
|
|
} |
71
|
2 |
|
|
72
|
|
|
/** |
73
|
2 |
|
* {@inheritDoc} |
74
|
2 |
|
* |
75
|
|
|
* @param array $data {@see \OpenStack\Networking\v2\Api::postNetwork} |
76
|
|
|
*/ |
77
|
|
|
public function create(array $data): Creatable |
78
|
|
|
{ |
79
|
|
|
$response = $this->execute($this->api->postNetwork(), $data); |
80
|
1 |
|
return $this->populateFromResponse($response); |
81
|
|
|
} |
82
|
1 |
|
|
83
|
1 |
|
/** |
84
|
|
|
* {@inheritDoc} |
85
|
|
|
*/ |
86
|
|
|
public function update() |
87
|
|
|
{ |
88
|
|
|
$response = $this->executeWithState($this->api->putNetwork()); |
89
|
1 |
|
$this->populateFromResponse($response); |
90
|
|
|
} |
91
|
1 |
|
|
92
|
1 |
|
/** |
93
|
|
|
* {@inheritDoc} |
94
|
|
|
*/ |
95
|
|
|
public function delete() |
96
|
|
|
{ |
97
|
|
|
$this->executeWithState($this->api->deleteNetwork()); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|