1 | <?php declare(strict_types=1); |
||
16 | class Port extends OperatorResource implements Creatable, Updateable, Deletable, Listable, Retrievable |
||
17 | { |
||
18 | use HasWaiterTrait; |
||
19 | |||
20 | /** |
||
21 | * The port status. Value is ACTIVE or DOWN. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | public $status; |
||
26 | |||
27 | /** |
||
28 | * The port name. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | public $name; |
||
33 | |||
34 | /** |
||
35 | * A set of zero or more allowed address pairs. An address pair consists of an IP address and MAC address. |
||
36 | * |
||
37 | * @var []string |
||
38 | */ |
||
39 | public $allowedAddressPairs; |
||
40 | |||
41 | /** |
||
42 | * The administrative state of the port, which is up (true) or down (false). |
||
43 | * |
||
44 | * @var bool |
||
45 | */ |
||
46 | public $adminStateUp; |
||
47 | |||
48 | /** |
||
49 | * The UUID of the attached network. |
||
50 | * |
||
51 | * @var string |
||
52 | */ |
||
53 | public $networkId; |
||
54 | |||
55 | /** |
||
56 | * The UUID of the tenant who owns the network. Only administrative users can specify a tenant UUID other than |
||
57 | * their own. |
||
58 | * |
||
59 | * @var string |
||
60 | */ |
||
61 | public $tenantId; |
||
62 | |||
63 | /** |
||
64 | * A set of zero or more extra DHCP option pairs. An option pair consists of an option value and name. |
||
65 | * |
||
66 | * @var array |
||
67 | */ |
||
68 | public $extraDhcpOpts; |
||
69 | |||
70 | /** |
||
71 | * The UUID of the entity that uses this port. For example, a DHCP agent. |
||
72 | * |
||
73 | * @var string |
||
74 | */ |
||
75 | public $deviceOwner; |
||
76 | |||
77 | /** |
||
78 | * The MAC address of the port. |
||
79 | * |
||
80 | * @var string |
||
81 | */ |
||
82 | public $macAddress; |
||
83 | |||
84 | /** |
||
85 | * The IP addresses for the port. Includes the IP address and UUID of the subnet. |
||
86 | * |
||
87 | * @var array |
||
88 | */ |
||
89 | public $fixedIps; |
||
90 | |||
91 | /** |
||
92 | * The UUID of the port. |
||
93 | * |
||
94 | * @var string |
||
95 | */ |
||
96 | public $id; |
||
97 | |||
98 | /** |
||
99 | * The UUIDs of any attached security groups. |
||
100 | * |
||
101 | * @var array |
||
102 | */ |
||
103 | public $securityGroups; |
||
104 | |||
105 | /** |
||
106 | * The UUID of the device that uses this port. For example, a virtual server. |
||
107 | * |
||
108 | * @var string |
||
109 | */ |
||
110 | public $deviceId; |
||
111 | |||
112 | /** |
||
113 | * The port security status. The status is enabled (true) or disabled (false). |
||
114 | * |
||
115 | * @var bool |
||
116 | */ |
||
117 | public $portSecurityEnabled; |
||
118 | |||
119 | protected $aliases = [ |
||
120 | 'admin_state_up' => 'adminStateUp', |
||
121 | 1 | 'display_name' => 'displayName', |
|
122 | 'network_id' => 'networkId', |
||
123 | 1 | 'tenant_id' => 'tenantId', |
|
124 | 1 | 'device_owner' => 'deviceOwner', |
|
125 | 'mac_address' => 'macAddress', |
||
126 | 'port_id' => 'portId', |
||
127 | 1 | 'security_groups' => 'securityGroups', |
|
128 | 'device_id' => 'deviceId', |
||
129 | 1 | 'fixed_ips' => 'fixedIps', |
|
130 | 1 | ]; |
|
131 | |||
132 | protected $resourceKey = 'port'; |
||
133 | 1 | ||
134 | /** |
||
135 | 1 | * {@inheritDoc} |
|
136 | 1 | */ |
|
137 | public function create(array $userOptions): Creatable |
||
138 | 1 | { |
|
139 | $response = $this->execute($this->api->postSinglePort(), $userOptions); |
||
140 | 1 | return $this->populateFromResponse($response); |
|
141 | 1 | } |
|
142 | |||
143 | public function bulkCreate(array $userOptions): array |
||
144 | { |
||
145 | $response = $this->execute($this->api->postMultiplePorts(), ['ports' => $userOptions]); |
||
146 | return $this->extractMultipleInstances($response); |
||
147 | } |
||
148 | |||
149 | public function retrieve() |
||
150 | { |
||
151 | $response = $this->execute($this->api->getPort(), ['id' => (string)$this->id]); |
||
152 | $this->populateFromResponse($response); |
||
153 | } |
||
154 | |||
155 | public function update() |
||
156 | { |
||
157 | i$response = $this->executeWithState($this->api->putPort()); |
||
|
|||
158 | $this->populateFromResponse($response); |
||
159 | } |
||
160 | |||
161 | public function delete() |
||
162 | { |
||
163 | $this->executeWithState($this->api->deletePort()); |
||
164 | } |
||
166 |