|
| 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 | +require dirname(__DIR__) . '/../vendor/autoload.php'; |
| 19 | + |
| 20 | +use OpenCloud\Rackspace; |
| 21 | + |
| 22 | +// 1. Instantiate a Rackspace client. You can replace {authUrl} with |
| 23 | +// Rackspace::US_IDENTITY_ENDPOINT or similar |
| 24 | +$client = new Rackspace('{authUrl}', array( |
| 25 | + 'username' => '{username}', |
| 26 | + 'apiKey' => '{apiKey}', |
| 27 | +)); |
| 28 | + |
| 29 | +// 2. Obtain a Networking service object from the client. |
| 30 | +$networkingService = $client->networkingService(null, '{region}'); |
| 31 | + |
| 32 | +// 3. List ACTIVE ports for given device ID |
| 33 | +$ports = $networkingService->listPorts([ |
| 34 | + 'status' => 'ACTIVE', |
| 35 | + 'device_id' => '{deviceId}' |
| 36 | +]); |
| 37 | +foreach ($ports as $port) { |
| 38 | + /** @var $port OpenCloud\Networking\Resource\Port **/ |
| 39 | +} |
0 commit comments