1: <?php
2: /**
3: * Copyright 2012-2014 Rackspace US, Inc.
4: *
5: * Licensed under the Apache License, Version 2.0 (the "License");
6: * you may not use this file except in compliance with the License.
7: * You may obtain a copy of the License at
8: *
9: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: namespace OpenCloud\Networking\Resource;
19:
20: use OpenCloud\Common\Resource\PersistentResource;
21:
22: /**
23: * A subnet represents an IP address block that can be used to assign IP
24: * addresses to virtual instances (such as servers created using the {@see
25: * \OpenCloud\Compute\Service}. Each subnet must have a CIDR and must be
26: * associated with a network.
27: *
28: * @see http://docs.openstack.org/api/openstack-network/2.0/content/Overview-d1e71.html#Subnet
29: *
30: * @package OpenCloud\Networking\Resource
31: */
32: class Subnet extends PersistentResource
33: {
34: protected static $url_resource = 'subnets';
35: protected static $json_name = 'subnet';
36:
37: protected $id;
38: protected $name;
39: protected $enableDhcp;
40: protected $networkId;
41: protected $dnsNameservers;
42: protected $allocationPools;
43: protected $hostRoutes;
44: protected $ipVersion;
45: protected $gatewayIp;
46: protected $cidr;
47: protected $tenantId;
48: protected $links;
49:
50: protected $aliases = array(
51: 'enable_dhcp' => 'enableDhcp',
52: 'network_id' => 'networkId',
53: 'dns_nameservers' => 'dnsNameservers',
54: 'allocation_pools' => 'allocationPools',
55: 'host_routes' => 'hostRoutes',
56: 'ip_version' => 'ipVersion',
57: 'gateway_ip' => 'gatewayIp',
58: 'tenant_id' => 'tenantId'
59: );
60:
61: protected $createKeys = array(
62: 'name',
63: 'enableDhcp',
64: 'networkId',
65: 'allocationPools',
66: 'hostRoutes',
67: 'ipVersion',
68: 'gatewayIp',
69: 'cidr',
70: 'tenantId'
71: );
72:
73: protected $updateKeys = array(
74: 'name',
75: 'enableDhcp',
76: 'hostRoutes',
77: 'gatewayIp'
78: );
79:
80: /**
81: * This method is inherited. The inherited method has protected scope
82: * but we are widening the scope to public so this method may be called
83: * from other classes such as {@see OpenCloud\Networking\Service}.
84: */
85: public function createJson()
86: {
87: return parent::createJson();
88: }
89: }
90: