Overview

Namespaces

  • OpenCloud
    • Autoscale
      • Resource
    • CDN
      • Resource
    • CloudMonitoring
      • Collection
      • Exception
      • Resource
    • Common
      • Collection
      • Constants
      • Exceptions
      • Http
        • Message
      • Log
      • Resource
      • Service
    • Compute
      • Constants
      • Exception
      • Resource
    • Database
      • Resource
    • DNS
      • Collection
      • Resource
    • Identity
      • Constants
      • Resource
    • Image
      • Enum
      • Resource
        • JsonPatch
        • Schema
    • LoadBalancer
      • Collection
      • Enum
      • Resource
    • Networking
      • Resource
    • ObjectStore
      • Constants
      • Enum
      • Exception
      • Resource
      • Upload
    • Orchestration
      • Resource
    • Queues
      • Collection
      • Exception
      • Resource
    • Volume
      • Resource
  • PHP

Classes

  • Service
  • Overview
  • Namespace
  • Class
  • Tree
  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\LoadBalancer;
 19: 
 20: use OpenCloud\Common\Log\Logger;
 21: use OpenCloud\Common\Service\NovaService;
 22: use OpenCloud\LoadBalancer\Collection\LoadBalancerIterator;
 23: 
 24: /**
 25:  * Class that encapsulates the Rackspace Cloud Load Balancers service
 26:  *
 27:  * @package OpenCloud\LoadBalancer
 28:  */
 29: class Service extends NovaService
 30: {
 31:     const DEFAULT_NAME = 'cloudLoadBalancers';
 32:     const DEFAULT_TYPE = 'rax:load-balancer';
 33: 
 34:     /**
 35:      * Return a Load Balancer
 36:      *
 37:      * @param string $id
 38:      * @return \OpenCloud\LoadBalancer\Resource\LoadBalancer
 39:      */
 40:     public function loadBalancer($id = null)
 41:     {
 42:         return $this->resource('LoadBalancer', $id);
 43:     }
 44: 
 45:     /**
 46:      * Return a paginated collection of load balancers
 47:      *
 48:      * @param bool $detail If TRUE, all details are returned; otherwise, a
 49:      *                     minimal set (ID, name) is retrieved [DEPRECATED]
 50:      * @param array $filter Optional query params used for search
 51:      * @return \OpenCloud\Common\Collection\PaginatedIterator
 52:      */
 53:     public function loadBalancerList($detail = true, array $filter = array())
 54:     {
 55:         $options = $this->makeResourceIteratorOptions($this->resolveResourceClass('LoadBalancer'));
 56: 
 57:         if (isset($filter['limit'])) {
 58:             $options['limit.page'] = $filter['limit'];
 59:             unset($filter['limit']);
 60:         }
 61: 
 62:         $url = $this->getUrl();
 63:         $url->addPath(Resource\LoadBalancer::resourceName());
 64:         $url->setQuery($filter);
 65: 
 66:         $options = array_merge($options, array('baseUrl' => $url, 'key.marker' => 'id'));
 67: 
 68:         return LoadBalancerIterator::factory($this, $options);
 69:     }
 70: 
 71:     /**
 72:      * @deprecated
 73:      */
 74:     public function billableLoadBalancer($id = null)
 75:     {
 76:         $this->getLogger()->warning(Logger::deprecated(__METHOD__, 'loadBalancer'));
 77: 
 78:         return $this->resource('LoadBalancer', $id);
 79:     }
 80: 
 81:     /**
 82:      * Returns a paginated collection of load balancers that have been billed
 83:      * between a certain period.
 84:      *
 85:      * @link http://docs.rackspace.com/loadbalancers/api/v1.0/clb-devguide/content/List_Usage-d1e3014.html
 86:      * @param array $filter
 87:      * @return \OpenCloud\Common\Collection\PaginatedIterator
 88:      */
 89:     public function billableLoadBalancerList(array $filter = array())
 90:     {
 91:         $url = $this->getUrl();
 92:         $url->addPath(Resource\LoadBalancer::resourceName());
 93:         $url->addPath('billable');
 94:         $url->setQuery($filter);
 95: 
 96:         return $this->resourceList('LoadBalancer', $url);
 97:     }
 98: 
 99:     /**
100:      * Returns an allowed domain
101:      *
102:      * @param mixed $data either an array of values or null
103:      * @return \OpenCloud\LoadBalancer\Resource\AllowedDomain
104:      */
105:     public function allowedDomain($data = null)
106:     {
107:         return $this->resource('AllowedDomain', $data);
108:     }
109: 
110:     /**
111:      * Returns Collection of AllowedDomain object
112:      *
113:      * @return \OpenCloud\Common\Collection\PaginatedIterator
114:      */
115:     public function allowedDomainList()
116:     {
117:         return $this->resourceList('AllowedDomain');
118:     }
119: 
120:     /**
121:      * single protocol (should never be called directly)
122:      *
123:      * Convenience method to be used by the ProtocolList Collection.
124:      *
125:      * @return \OpenCloud\LoadBalancer\Resource\Protocol
126:      */
127:     public function protocol($data = null)
128:     {
129:         return $this->resource('Protocol', $data);
130:     }
131: 
132:     /**
133:      * Returns a list of Protocol objects
134:      *
135:      * @return \OpenCloud\Common\Collection\PaginatedIterator
136:      */
137:     public function protocolList()
138:     {
139:         return $this->resourceList('Protocol');
140:     }
141: 
142:     /**
143:      * single algorithm (should never be called directly)
144:      *
145:      * convenience method used by the Collection factory
146:      *
147:      * @return \OpenCloud\LoadBalancer\Resource\Algorithm
148:      */
149:     public function algorithm($data = null)
150:     {
151:         return $this->resource('Algorithm', $data);
152:     }
153: 
154:     /**
155:      * Return a list of Algorithm objects
156:      *
157:      * @return \OpenCloud\Common\Collection\PaginatedIterator
158:      */
159:     public function algorithmList()
160:     {
161:         return $this->resourceList('Algorithm');
162:     }
163: }
164: 
API documentation generated by ApiGen 2.8.0