File indexing completed on 2024-12-22 05:37:01

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Service
0017  * @subpackage Amazon
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 /**
0024  * Amazon Ec2 Interface to allow easy creation of the Ec2 Components
0025  *
0026  * @category   Zend
0027  * @package    Zend_Service
0028  * @subpackage Amazon
0029  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0030  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0031  */
0032 class Zend_Service_Amazon_Ec2
0033 {
0034     /**
0035      * Factory method to fetch what you want to work with.
0036      *
0037      * @param string $section           Create the method that you want to work with
0038      * @param string $key               Override the default aws key
0039      * @param string $secret_key        Override the default aws secretkey
0040      * @throws Zend_Service_Amazon_Ec2_Exception
0041      * @return object
0042      */
0043     public static function factory($section, $key = null, $secret_key = null)
0044     {
0045         switch(strtolower($section)) {
0046             case 'keypair':
0047                 $class = 'Zend_Service_Amazon_Ec2_Keypair';
0048                 break;
0049             case 'eip':
0050                 // break left out
0051             case 'elasticip':
0052                 $class = 'Zend_Service_Amazon_Ec2_Elasticip';
0053                 break;
0054             case 'ebs':
0055                 $class = 'Zend_Service_Amazon_Ec2_Ebs';
0056                 break;
0057             case 'availabilityzones':
0058                 // break left out
0059             case 'zones':
0060                 $class = 'Zend_Service_Amazon_Ec2_Availabilityzones';
0061                 break;
0062             case 'ami':
0063                 // break left out
0064             case 'image':
0065                 $class = 'Zend_Service_Amazon_Ec2_Image';
0066                 break;
0067             case 'instance':
0068                 $class = 'Zend_Service_Amazon_Ec2_Instance';
0069                 break;
0070             case 'security':
0071                 // break left out
0072             case 'securitygroups':
0073                 $class = 'Zend_Service_Amazon_Ec2_Securitygroups';
0074                 break;
0075             default:
0076                 throw new Zend_Service_Amazon_Ec2_Exception('Invalid Section: ' . $section);
0077                 break;
0078         }
0079 
0080         if (!class_exists($class)) {
0081             // require_once 'Zend/Loader.php';
0082             Zend_Loader::loadClass($class);
0083         }
0084         return new $class($key, $secret_key);
0085     }
0086 }
0087