Overview

Namespaces

  • None
  • OpenCloud
    • Autoscale
      • Resource
    • CloudMonitoring
      • Exception
      • Resource
    • Common
      • Exceptions
      • Log
      • Request
        • Response
    • Compute
    • Database
    • DNS
    • LoadBalancer
      • Resources
    • ObjectStore
      • Resource
    • Orchestration
    • Volume
  • PHP

Classes

  • Service
  • Overview
  • Namespace
  • Class
  • Tree
  • Download
  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\Nova;
 15: use OpenCloud\OpenStack;
 16: 
 17: /**
 18:  * The Rackspace Cloud Load Balancers
 19:  */
 20: class Service extends Nova
 21: {
 22: 
 23:     const SERVICE_TYPE = 'rax:load-balancer';
 24:     const SERVICE_OBJECT_CLASS = 'LoadBalancer';
 25:     const URL_RESOURCE = 'loadbalancers';
 26:     const JSON_ELEMENT = 'loadBalancers';
 27: 
 28:     /**
 29:      * Creates a new LoadBalancerService connection
 30:      *
 31:      * This is not normally called directly, but via the factory method on the
 32:      * OpenStack or Rackspace connection object.
 33:      *
 34:      * @param OpenStack $conn the connection on which to create the service
 35:      * @param string $name the name of the service (e.g., "cloudDatabases")
 36:      * @param string $region the region of the service (e.g., "DFW" or "LON")
 37:      * @param string $urltype the type of URL (normally "publicURL")
 38:      */
 39:     public function __construct(OpenStack $conn, $name, $region, $urltype) 
 40:     {
 41:         parent::__construct($conn, self::SERVICE_TYPE, $name, $region, $urltype);
 42:     }
 43: 
 44:     /**
 45:      * Returns the URL of this service, or optionally that of
 46:      * an instance
 47:      *
 48:      * @param string $resource the resource required
 49:      * @param array $args extra arguments to pass to the URL as query strings
 50:      */
 51:     public function url($resource = self::URL_RESOURCE, array $args = array()) 
 52:     {
 53:         return parent::url($resource, $args);
 54:     }
 55: 
 56:     /**
 57:      * creates a new LoadBalancer object
 58:      *
 59:      * @api
 60:      * @param string $id the identifier of the load balancer
 61:      * @return LoadBalancerService\LoadBalancer
 62:      */
 63:     public function loadBalancer($id = null) 
 64:     {
 65:         return new Resources\LoadBalancer($this, $id);
 66:     }
 67: 
 68:     /**
 69:      * returns a Collection of LoadBalancer objects
 70:      *
 71:      * @api
 72:      * @param boolean $detail if TRUE (the default), then all details are
 73:      *      returned; otherwise, the minimal set (ID, name) are retrieved
 74:      * @param array $filter if provided, a set of key/value pairs that are
 75:      *      set as query string parameters to the query
 76:      * @return \OpenCloud\Collection
 77:      */
 78:     public function loadBalancerList($detail = true, $filter = array()) 
 79:     {
 80:         return $this->collection('OpenCloud\LoadBalancer\Resources\LoadBalancer');
 81:     }
 82: 
 83:     /**
 84:      * creates a new BillableLoadBalancer object (read-only)
 85:      *
 86:      * @api
 87:      * @param string $id the identifier of the load balancer
 88:      * @return LoadBalancerService\LoadBalancer
 89:      */
 90:     public function billableLoadBalancer($id = null) 
 91:     {
 92:         return new Resources\BillableLoadBalancer($this, $id);
 93:     }
 94: 
 95:     /**
 96:      * returns a Collection of BillableLoadBalancer objects
 97:      *
 98:      * @api
 99:      * @param boolean $detail if TRUE (the default), then all details are
100:      *      returned; otherwise, the minimal set (ID, name) are retrieved
101:      * @param array $filter if provided, a set of key/value pairs that are
102:      *      set as query string parameters to the query
103:      * @return \OpenCloud\Collection
104:      */
105:     public function billableLoadBalancerList($detail = true, $filter = array()) 
106:     {
107:         $class = 'OpenCloud\LoadBalancer\Resources\BillableLoadBalancer';
108:         $url = $this->url($class::ResourceName(), $filter);
109:         return $this->collection($class, $url);
110:     }
111: 
112:     /**
113:      * returns allowed domain
114:      *
115:      * @api
116:      * @param mixed $data either an array of values or null
117:      * @return LoadBalancerService\AllowedDomain
118:      */
119:     public function allowedDomain($data = null) 
120:     {
121:         return new Resources\AllowedDomain($this, $data);
122:     }
123: 
124:     /**
125:      * returns Collection of AllowedDomain object
126:      *
127:      * @api
128:      * @return Collection
129:      */
130:     public function allowedDomainList() 
131:     {
132:         return $this->collection('OpenCloud\LoadBalancer\Resources\AllowedDomain', null, $this);
133:     }
134: 
135:     /**
136:      * single protocol (should never be called directly)
137:      *
138:      * Convenience method to be used by the ProtocolList Collection.
139:      *
140:      * @return LoadBalancerService\Protocol
141:      */
142:     public function protocol($data = null) 
143:     {
144:         return new Resources\Protocol($this, $data);
145:     }
146: 
147:     /**
148:      * a list of Protocol objects
149:      *
150:      * @api
151:      * @return Collection
152:      */
153:     public function protocolList() 
154:     {
155:         return $this->collection('OpenCloud\LoadBalancer\Resources\Protocol', null, $this);
156:     }
157: 
158:     /**
159:      * single algorithm (should never be called directly)
160:      *
161:      * convenience method used by the Collection factory
162:      *
163:      * @return LoadBalancerService\Algorithm
164:      */
165:     public function algorithm($data = null) 
166:     {
167:         return new Resources\Algorithm($this, $data);
168:     }
169: 
170:     /**
171:      * a list of Algorithm objects
172:      *
173:      * @api
174:      * @return Collection
175:      */
176:     public function algorithmList() 
177:     {
178:         return $this->collection('OpenCloud\LoadBalancer\Resources\Algorithm', null, $this);
179:     }
180: 
181: }
182: 
PHP OpenCloud API API documentation generated by ApiGen 2.8.0