GetAsynchronousOperation.php 6.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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_Console
  17. * @subpackage Exception
  18. * @version $Id$
  19. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  20. * @license http://framework.zend.com/license/new-bsd New BSD License
  21. */
  22. /**
  23. * Asynchronous Operation commands
  24. *
  25. * @category Zend
  26. * @package Zend_Service_WindowsAzure_CommandLine
  27. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  28. * @license http://framework.zend.com/license/new-bsd New BSD License
  29. *
  30. * @command-handler getasynchronousoperation
  31. * @command-handler-description Windows Azure Asynchronous Operation commands
  32. * @command-handler-header Windows Azure SDK for PHP
  33. * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
  34. * @command-handler-footer Note: Parameters that are common across all commands can be stored
  35. * @command-handler-footer in two dedicated environment variables.
  36. * @command-handler-footer - SubscriptionId: The Windows Azure Subscription Id to operate on.
  37. * @command-handler-footer - Certificate The Windows Azure .cer Management Certificate.
  38. * @command-handler-footer
  39. * @command-handler-footer All commands support the --ConfigurationFile or -F parameter.
  40. * @command-handler-footer The parameter file is a simple INI file carrying one parameter
  41. * @command-handler-footer value per line. It accepts the same parameters as one can
  42. * @command-handler-footer use from the command line command.
  43. */
  44. class Zend_Service_WindowsAzure_CommandLine_GetAsynchronousOperation
  45. extends Zend_Service_Console_Command
  46. {
  47. /**
  48. * Get information for a specific asynchronous request.
  49. *
  50. * @command-name GetInfo
  51. * @command-description Get information for a specific asynchronous request.
  52. * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
  53. * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
  54. * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed.
  55. * @command-parameter-for $requestId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --RequestId|-r Required. The value returned by a call that starts an asynchronous operation to monitor.
  56. * @command-example Get information for a specific asynchronous operation:
  57. * @command-example GetInfo -sid:"<your_subscription_id>" -cert:"mycert.pem" -r:"dab87a4b70e94a36805f5af2d20fc593"
  58. */
  59. public function getInfoCommand($subscriptionId, $certificate, $certificatePassphrase, $requestId)
  60. {
  61. $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
  62. $result = $client->getOperationStatus($requestId);
  63. $this->_displayObjectInformation($result, array('ID', 'Status', 'ErrorMessage'));
  64. }
  65. /**
  66. * Wait for a specific asynchronous request to complete.
  67. *
  68. * @command-name WaitFor
  69. * @command-description Wait for a specific asynchronous request to complete.
  70. * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
  71. * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
  72. * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed.
  73. * @command-parameter-for $requestId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --RequestId|-r Required. The value returned by a call that starts an asynchronous operation to monitor.
  74. * @command-parameter-for $interval Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Interval|-i Optional. The interval between two status checks (in milliseconds).
  75. * @command-example Wait for a specific asynchronous operation:
  76. * @command-example WaitFor -sid:"<your_subscription_id>" -cert:"mycert.pem" -r:"dab87a4b70e94a36805f5af2d20fc593"
  77. */
  78. public function waitForCommand($subscriptionId, $certificate, $certificatePassphrase, $requestId, $interval = 250)
  79. {
  80. $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
  81. $client->waitForOperation($requestId, $interval);
  82. }
  83. }
  84. Zend_Service_Console_Command::bootstrap($_SERVER['argv']);