1: <?php
2: /**
3: * PHP OpenCloud library.
4: *
5: * @copyright Copyright 2013 Rackspace US, Inc. See COPYING for licensing information.
6: * @license https://www.apache.org/licenses/LICENSE-2.0 Apache 2.0
7: * @version 1.6.0
8: * @author Glen Campbell <glen.campbell@rackspace.com>
9: * @author Jamie Hannaford <jamie.hannaford@rackspace.com>
10: */
11:
12: namespace OpenCloud\LoadBalancer;
13:
14: use OpenCloud\Common\Service\NovaService;
15: use OpenCloud\OpenStack;
16:
17: /**
18: * The Rackspace Cloud Load Balancers
19: */
20: class Service extends NovaService
21: {
22: const DEFAULT_NAME = 'cloudLoadBalancers';
23: const DEFAULT_TYPE = 'rax:load-balancer';
24:
25: /**
26: * creates a new LoadBalancer object
27: *
28: * @api
29: * @param string $id the identifier of the load balancer
30: * @return LoadBalancerService\LoadBalancer
31: */
32: public function loadBalancer($id = null)
33: {
34: return new Resource\LoadBalancer($this, $id);
35: }
36:
37: /**
38: * returns a Collection of LoadBalancer objects
39: *
40: * @api
41: * @param boolean $detail if TRUE (the default), then all details are
42: * returned; otherwise, the minimal set (ID, name) are retrieved
43: * @param array $filter if provided, a set of key/value pairs that are
44: * set as query string parameters to the query
45: * @return \OpenCloud\Collection
46: */
47: public function loadBalancerList($detail = true, $filter = array())
48: {
49: return $this->collection('OpenCloud\LoadBalancer\Resource\LoadBalancer');
50: }
51:
52: /**
53: * creates a new BillableLoadBalancer object (read-only)
54: *
55: * @api
56: * @param string $id the identifier of the load balancer
57: * @return LoadBalancerService\LoadBalancer
58: */
59: public function billableLoadBalancer($id = null)
60: {
61: return new Resource\BillableLoadBalancer($this, $id);
62: }
63:
64: /**
65: * returns a Collection of BillableLoadBalancer objects
66: *
67: * @api
68: * @param boolean $detail if TRUE (the default), then all details are
69: * returned; otherwise, the minimal set (ID, name) are retrieved
70: * @param array $filter if provided, a set of key/value pairs that are
71: * set as query string parameters to the query
72: * @return \OpenCloud\Collection
73: */
74: public function billableLoadBalancerList($detail = true, $filter = array())
75: {
76: $class = 'OpenCloud\LoadBalancer\Resource\BillableLoadBalancer';
77: $url = $this->url($class::ResourceName(), $filter);
78: return $this->collection($class, $url);
79: }
80:
81: /**
82: * returns allowed domain
83: *
84: * @api
85: * @param mixed $data either an array of values or null
86: * @return LoadBalancerService\AllowedDomain
87: */
88: public function allowedDomain($data = null)
89: {
90: return new Resource\AllowedDomain($this, $data);
91: }
92:
93: /**
94: * returns Collection of AllowedDomain object
95: *
96: * @api
97: * @return Collection
98: */
99: public function allowedDomainList()
100: {
101: return $this->collection('OpenCloud\LoadBalancer\Resource\AllowedDomain', null, $this);
102: }
103:
104: /**
105: * single protocol (should never be called directly)
106: *
107: * Convenience method to be used by the ProtocolList Collection.
108: *
109: * @return LoadBalancerService\Protocol
110: */
111: public function protocol($data = null)
112: {
113: return new Resource\Protocol($this, $data);
114: }
115:
116: /**
117: * a list of Protocol objects
118: *
119: * @api
120: * @return Collection
121: */
122: public function protocolList()
123: {
124: return $this->collection('OpenCloud\LoadBalancer\Resource\Protocol', null, $this);
125: }
126:
127: /**
128: * single algorithm (should never be called directly)
129: *
130: * convenience method used by the Collection factory
131: *
132: * @return LoadBalancerService\Algorithm
133: */
134: public function algorithm($data = null)
135: {
136: return new Resource\Algorithm($this, $data);
137: }
138:
139: /**
140: * a list of Algorithm objects
141: *
142: * @api
143: * @return Collection
144: */
145: public function algorithmList()
146: {
147: return $this->collection('OpenCloud\LoadBalancer\Resource\Algorithm', null, $this);
148: }
149:
150: }
151: