web/lib/Zend/Service/WindowsAzure/CommandLine/GetAsynchronousOperation.php
changeset 808 6b6c2214f778
child 1230 68c69c656a2c
equal deleted inserted replaced
807:877f952ae2bd 808:6b6c2214f778
       
     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 /**
       
    24  * Asynchronous Operation commands
       
    25  * 
       
    26  * @category   Zend
       
    27  * @package    Zend_Service_WindowsAzure_CommandLine
       
    28  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
       
    29  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    30  * 
       
    31  * @command-handler getasynchronousoperation
       
    32  * @command-handler-description Windows Azure Asynchronous Operation commands
       
    33  * @command-handler-header Windows Azure SDK for PHP
       
    34  * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
       
    35  * @command-handler-footer Note: Parameters that are common across all commands can be stored 
       
    36  * @command-handler-footer in two dedicated environment variables.
       
    37  * @command-handler-footer - SubscriptionId: The Windows Azure Subscription Id to operate on.
       
    38  * @command-handler-footer - Certificate The Windows Azure .cer Management Certificate.
       
    39  * @command-handler-footer 
       
    40  * @command-handler-footer All commands support the --ConfigurationFile or -F parameter.
       
    41  * @command-handler-footer The parameter file is a simple INI file carrying one parameter
       
    42  * @command-handler-footer value per line. It accepts the same parameters as one can
       
    43  * @command-handler-footer use from the command line command.
       
    44  */
       
    45 class Zend_Service_WindowsAzure_CommandLine_GetAsynchronousOperation
       
    46 	extends Zend_Service_Console_Command
       
    47 {	
       
    48 	/**
       
    49 	 * Get information for a specific asynchronous request.
       
    50 	 * 
       
    51 	 * @command-name GetInfo
       
    52 	 * @command-description Get information for a specific asynchronous request.
       
    53 	 * @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.
       
    54 	 * @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.
       
    55 	 * @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.
       
    56 	 * @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.
       
    57 	 * @command-example Get information for a specific asynchronous operation:
       
    58 	 * @command-example GetInfo -sid:"<your_subscription_id>" -cert:"mycert.pem" -r:"dab87a4b70e94a36805f5af2d20fc593"
       
    59 	 */
       
    60 	public function getInfoCommand($subscriptionId, $certificate, $certificatePassphrase, $requestId)
       
    61 	{
       
    62 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
       
    63 		$result = $client->getOperationStatus($requestId);
       
    64 
       
    65 		$this->_displayObjectInformation($result, array('ID', 'Status', 'ErrorMessage'));
       
    66 	}
       
    67 	
       
    68 	/**
       
    69 	 * Wait for a specific asynchronous request to complete.
       
    70 	 * 
       
    71 	 * @command-name WaitFor
       
    72 	 * @command-description Wait for a specific asynchronous request to complete.
       
    73 	 * @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.
       
    74 	 * @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.
       
    75 	 * @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.
       
    76 	 * @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.
       
    77 	 * @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).
       
    78 	 * @command-example Wait for a specific asynchronous operation:
       
    79 	 * @command-example WaitFor -sid:"<your_subscription_id>" -cert:"mycert.pem" -r:"dab87a4b70e94a36805f5af2d20fc593"
       
    80 	 */
       
    81 	public function waitForCommand($subscriptionId, $certificate, $certificatePassphrase, $requestId, $interval = 250)
       
    82 	{
       
    83 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
       
    84 		$client->waitForOperation($requestId, $interval);
       
    85 	}
       
    86 }
       
    87 
       
    88 Zend_Service_Console_Command::bootstrap($_SERVER['argv']);