|
| 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 | +// |
| 19 | +// Pre-requisites: |
| 20 | +// * Prior to running this script, you must setup the following environment variables: |
| 21 | +// * OS_AUTH_URL: Your Rackspace Cloud Authentication URL, |
| 22 | +// * OS_USERNAME: Your Rackspace Cloud Account Username, |
| 23 | +// * RAX_API_KEY: Your Rackspace Cloud Account API KEY, and |
| 24 | +// * OS_REGION_NAME: The Rackspace Cloud region you want to use |
| 25 | +// |
| 26 | + |
| 27 | +require __DIR__ . '/../../vendor/autoload.php'; |
| 28 | +use OpenCloud\Rackspace; |
| 29 | + |
| 30 | +// 1. Instantiate an Rackspace client. |
| 31 | +$client = new Rackspace(getenv('OS_AUTH_URL'), array( |
| 32 | + 'username' => getenv('OS_USERNAME'), |
| 33 | + 'apiKey' => getenv('RAX_API_KEY') |
| 34 | +)); |
| 35 | + |
| 36 | +// 2. Obtain an LoadBalancer service object from the client. |
| 37 | +$region = getenv('OS_REGION_NAME'); |
| 38 | +$loadBalancerService = $client->loadBalancerService(null, $region); |
| 39 | + |
| 40 | +// 3. Get load balancers. |
| 41 | +$loadBalancers = $loadBalancerService->loadBalancerList(); |
| 42 | +foreach ($loadBalancers as $loadBalancer) { |
| 43 | + /** @var $loadBalancer OpenCloud\LoadBalancer\Resource\LoadBalancer **/ |
| 44 | + var_dump($loadBalancer); |
| 45 | +} |
0 commit comments