Ec2.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Service
  17. * @subpackage Amazon
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * Amazon Ec2 Interface to allow easy creation of the Ec2 Components
  24. *
  25. * @category Zend
  26. * @package Zend_Service
  27. * @subpackage Amazon
  28. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. */
  31. class Zend_Service_Amazon_Ec2
  32. {
  33. /**
  34. * Factory method to fetch what you want to work with.
  35. *
  36. * @param string $section Create the method that you want to work with
  37. * @param string $key Override the default aws key
  38. * @param string $secret_key Override the default aws secretkey
  39. * @throws Zend_Service_Amazon_Ec2_Exception
  40. * @return object
  41. */
  42. public static function factory($section, $key = null, $secret_key = null)
  43. {
  44. switch(strtolower($section)) {
  45. case 'keypair':
  46. $class = 'Zend_Service_Amazon_Ec2_Keypair';
  47. break;
  48. case 'eip':
  49. // break left out
  50. case 'elasticip':
  51. $class = 'Zend_Service_Amazon_Ec2_Elasticip';
  52. break;
  53. case 'ebs':
  54. $class = 'Zend_Service_Amazon_Ec2_Ebs';
  55. break;
  56. case 'availabilityzones':
  57. // break left out
  58. case 'zones':
  59. $class = 'Zend_Service_Amazon_Ec2_Availabilityzones';
  60. break;
  61. case 'ami':
  62. // break left out
  63. case 'image':
  64. $class = 'Zend_Service_Amazon_Ec2_Image';
  65. break;
  66. case 'instance':
  67. $class = 'Zend_Service_Amazon_Ec2_Instance';
  68. break;
  69. case 'security':
  70. // break left out
  71. case 'securitygroups':
  72. $class = 'Zend_Service_Amazon_Ec2_Securitygroups';
  73. break;
  74. default:
  75. throw new Zend_Service_Amazon_Ec2_Exception('Invalid Section: ' . $section);
  76. break;
  77. }
  78. if (!class_exists($class)) {
  79. require_once 'Zend/Loader.php';
  80. Zend_Loader::loadClass($class);
  81. }
  82. return new $class($key, $secret_key);
  83. }
  84. }