web/lib/Zend/Service/WindowsAzure/CommandLine/Service.php
changeset 1230 68c69c656a2c
parent 808 6b6c2214f778
equal deleted inserted replaced
1229:5a6b6e770365 1230:68c69c656a2c
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Service_Console
    16  * @package    Zend_Service_Console
    17  * @subpackage Exception
    17  * @subpackage Exception
    18  * @version    $Id$
    18  * @version    $Id$
    19  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    21  */
    21  */
    22 
    22 
       
    23 /**
       
    24 * @see Zend_Service_Console_Command
       
    25 */
       
    26 require_once 'Zend/Service/Console/Command.php';
       
    27 
       
    28 /**
       
    29 * @see Zend_Service_WindowsAzure_Management_Client
       
    30 */
       
    31 require_once 'Zend/Service/WindowsAzure/Management/Client.php';
    23 
    32 
    24 /**
    33 /**
    25  * Service commands
    34  * Service commands
    26  * 
    35  *
    27  * @category   Zend
    36  * @category   Zend
    28  * @package    Zend_Service_WindowsAzure_CommandLine
    37  * @package    Zend_Service_WindowsAzure_CommandLine
    29  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    38  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    30  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    39  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    31  * 
    40  *
    32  * @command-handler service
    41  * @command-handler service
    33  * @command-handler-description Windows Azure Service commands
    42  * @command-handler-description Windows Azure Service commands
    34  * @command-handler-header Windows Azure SDK for PHP
    43  * @command-handler-header Windows Azure SDK for PHP
    35  * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
    44  * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
    36  * @command-handler-footer Note: Parameters that are common across all commands can be stored 
    45  * @command-handler-footer Note: Parameters that are common across all commands can be stored
    37  * @command-handler-footer in two dedicated environment variables.
    46  * @command-handler-footer in two dedicated environment variables.
    38  * @command-handler-footer - SubscriptionId: The Windows Azure Subscription Id to operate on.
    47  * @command-handler-footer - SubscriptionId: The Windows Azure Subscription Id to operate on.
    39  * @command-handler-footer - Certificate The Windows Azure .cer Management Certificate.
    48  * @command-handler-footer - Certificate The Windows Azure .cer Management Certificate.
    40  * @command-handler-footer 
    49  * @command-handler-footer
    41  * @command-handler-footer All commands support the --ConfigurationFile or -F parameter.
    50  * @command-handler-footer All commands support the --ConfigurationFile or -F parameter.
    42  * @command-handler-footer The parameter file is a simple INI file carrying one parameter
    51  * @command-handler-footer The parameter file is a simple INI file carrying one parameter
    43  * @command-handler-footer value per line. It accepts the same parameters as one can
    52  * @command-handler-footer value per line. It accepts the same parameters as one can
    44  * @command-handler-footer use from the command line command.
    53  * @command-handler-footer use from the command line command.
    45  */
    54  */
    46 class Zend_Service_WindowsAzure_CommandLine_Service
    55 class Zend_Service_WindowsAzure_CommandLine_Service
    47 	extends Zend_Service_Console_Command
    56 	extends Zend_Service_Console_Command
    48 {	
    57 {
    49 	/**
    58 	/**
    50 	 * List hosted service accounts for a specified subscription.
    59 	 * List hosted service accounts for a specified subscription.
    51 	 * 
    60 	 *
    52 	 * @command-name List
    61 	 * @command-name List
    53 	 * @command-description List hosted service accounts for a specified subscription.
    62 	 * @command-description List hosted service accounts for a specified subscription.
    54 	 * @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.
    63 	 * @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.
    55 	 * @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.
    64 	 * @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.
    56 	 * @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.
    65 	 * @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.
    67 		}
    76 		}
    68 		foreach ($result as $object) {
    77 		foreach ($result as $object) {
    69 			$this->_displayObjectInformation($object, array('ServiceName', 'Url'));
    78 			$this->_displayObjectInformation($object, array('ServiceName', 'Url'));
    70 		}
    79 		}
    71 	}
    80 	}
    72 	
    81 
    73 	/**
    82 	/**
    74 	 * Get hosted service account properties.
    83 	 * Get hosted service account properties.
    75 	 * 
    84 	 *
    76 	 * @command-name GetProperties
    85 	 * @command-name GetProperties
    77 	 * @command-description Get hosted service account properties.
    86 	 * @command-description Get hosted service account properties.
    78 	 * @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.
    87 	 * @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.
    79 	 * @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.
    88 	 * @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.
    80 	 * @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.
    89 	 * @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.
    85 	 */
    94 	 */
    86 	public function getPropertiesCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName)
    95 	public function getPropertiesCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName)
    87 	{
    96 	{
    88 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
    97 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
    89 		$result = $client->getHostedServiceProperties($serviceName);
    98 		$result = $client->getHostedServiceProperties($serviceName);
    90 		
    99 
    91 		$this->_displayObjectInformation($result, array('ServiceName', 'Label', 'AffinityGroup', 'Location'));
   100 		$this->_displayObjectInformation($result, array('ServiceName', 'Label', 'AffinityGroup', 'Location'));
    92 	}
   101 	}
    93 	
   102 
    94 	/**
   103 	/**
    95 	 * Get hosted service account property.
   104 	 * Get hosted service account property.
    96 	 * 
   105 	 *
    97 	 * @command-name GetProperty
   106 	 * @command-name GetProperty
    98 	 * @command-description Get storage account property.
   107 	 * @command-description Get storage account property.
    99 	 * @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.
   108 	 * @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.
   100 	 * @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.
   109 	 * @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.
   101 	 * @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.
   110 	 * @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.
   107 	 */
   116 	 */
   108 	public function getPropertyCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $property)
   117 	public function getPropertyCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $property)
   109 	{
   118 	{
   110 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
   119 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
   111 		$result = $client->getHostedServiceProperties($serviceName);
   120 		$result = $client->getHostedServiceProperties($serviceName);
   112 		
   121 
   113 		printf("%s\r\n", $result->$property);
   122 		printf("%s\r\n", $result->$property);
   114 	}
   123 	}
   115 	
   124 
   116 	/**
   125 	/**
   117 	 * Create hosted service account.
   126 	 * Create hosted service account.
   118 	 * 
   127 	 *
   119 	 * @command-name Create
   128 	 * @command-name Create
   120 	 * @command-description Create hosted service account.
   129 	 * @command-description Create hosted service account.
   121 	 * @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.
   130 	 * @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.
   122 	 * @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.
   131 	 * @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.
   123 	 * @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.
   132 	 * @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.
   137 		if ($waitForOperation) {
   146 		if ($waitForOperation) {
   138 			$client->waitForOperation();
   147 			$client->waitForOperation();
   139 		}
   148 		}
   140 		echo $client->getLastRequestId();
   149 		echo $client->getLastRequestId();
   141 	}
   150 	}
   142 	
   151 
   143 	/**
   152 	/**
   144 	 * Update hosted service account.
   153 	 * Update hosted service account.
   145 	 * 
   154 	 *
   146 	 * @command-name Update
   155 	 * @command-name Update
   147 	 * @command-description Update hosted service account.
   156 	 * @command-description Update hosted service account.
   148 	 * @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.
   157 	 * @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.
   149 	 * @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.
   158 	 * @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.
   150 	 * @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.
   159 	 * @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.
   162 		if ($waitForOperation) {
   171 		if ($waitForOperation) {
   163 			$client->waitForOperation();
   172 			$client->waitForOperation();
   164 		}
   173 		}
   165 		echo $client->getLastRequestId();
   174 		echo $client->getLastRequestId();
   166 	}
   175 	}
   167 	
   176 
   168 	/**
   177 	/**
   169 	 * Delete hosted service account.
   178 	 * Delete hosted service account.
   170 	 * 
   179 	 *
   171 	 * @command-name Delete
   180 	 * @command-name Delete
   172 	 * @command-description Delete hosted service account.
   181 	 * @command-description Delete hosted service account.
   173 	 * @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.
   182 	 * @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.
   174 	 * @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.
   183 	 * @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.
   175 	 * @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.
   184 	 * @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.