Microsoft_Console
[ class tree: Microsoft_Console ] [ index: Microsoft_Console ] [ all elements ]

Source for file Service.php

Documentation is available at Service.php

  1. <?php
  2. /**
  3.  * Copyright (c) 2009 - 2011, RealDolmen
  4.  * All rights reserved.
  5.  *
  6.  * Redistribution and use in source and binary forms, with or without
  7.  * modification, are permitted provided that the following conditions are met:
  8.  *     * Redistributions of source code must retain the above copyright
  9.  *       notice, this list of conditions and the following disclaimer.
  10.  *     * Redistributions in binary form must reproduce the above copyright
  11.  *       notice, this list of conditions and the following disclaimer in the
  12.  *       documentation and/or other materials provided with the distribution.
  13.  *     * Neither the name of RealDolmen nor the
  14.  *       names of its contributors may be used to endorse or promote products
  15.  *       derived from this software without specific prior written permission.
  16.  *
  17.  * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
  18.  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20.  * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
  21.  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22.  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23.  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26.  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27.  *
  28.  * @category   Microsoft
  29.  * @package    Microsoft_Console
  30.  * @subpackage Exception
  31.  * @version    $Id: Exception.php 55733 2011-01-03 09:17:16Z unknown $
  32.  * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
  33.  * @license    http://phpazure.codeplex.com/license
  34.  */
  35.  
  36. /**
  37.  * @see Microsoft_AutoLoader
  38.  */
  39. require_once dirname(__FILE__'/../../AutoLoader.php';
  40.  
  41. /**
  42.  * Service commands
  43.  * 
  44.  * @category   Microsoft
  45.  * @package    Microsoft_WindowsAzure_CommandLine
  46.  * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
  47.  * @license    http://phpazure.codeplex.com/license
  48.  * 
  49.  * @command-handler service
  50.  * @command-handler-description Windows Azure Service commands
  51.  * @command-handler-header Windows Azure SDK for PHP
  52.  * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
  53.  * @command-handler-footer Note: Parameters that are common across all commands can be stored
  54.  * @command-handler-footer in two dedicated environment variables.
  55.  * @command-handler-footer - SubscriptionId: The Windows Azure Subscription Id to operate on.
  56.  * @command-handler-footer - Certificate The Windows Azure .cer Management Certificate.
  57.  * @command-handler-footer
  58.  * @command-handler-footer All commands support the --ConfigurationFile or -F parameter.
  59.  * @command-handler-footer The parameter file is a simple INI file carrying one parameter
  60.  * @command-handler-footer value per line. It accepts the same parameters as one can
  61.  * @command-handler-footer use from the command line command.
  62.  */
  63.     extends Microsoft_Console_Command
  64. {    
  65.     /**
  66.      * List hosted service accounts for a specified subscription.
  67.      * 
  68.      * @command-name List
  69.      * @command-description List hosted service accounts for a specified subscription.
  70.      * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
  71.      * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_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 Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
  73.      * @command-example List hosted service accounts for subscription:
  74.      * @command-example List -sid="<your_subscription_id>" -cert="mycert.pem"
  75.      */
  76.     public function listCommand($subscriptionId$certificate$certificatePassphrase)
  77.     {
  78.         $client new Microsoft_WindowsAzure_Management_Client($subscriptionId$certificate$certificatePassphrase);
  79.         $result $client->listHostedServices();
  80.  
  81.         if (count($result== 0{
  82.             echo 'No data to display.';
  83.         }
  84.         foreach ($result as $object{
  85.             $this->_displayObjectInformation($objectarray('ServiceName''Url'));
  86.         }
  87.     }
  88.     
  89.     /**
  90.      * Get hosted service account properties.
  91.      * 
  92.      * @command-name GetProperties
  93.      * @command-description Get hosted service account properties.
  94.      * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
  95.      * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
  96.      * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
  97.      * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env|Microsoft_Console_Command_ParameterSource_StdIn --Name Required. The hosted service DNS name to operate on.
  98.      * @command-example Get hosted service account properties for service "phptest":
  99.      * @command-example GetProperties -sid="<your_subscription_id>" -cert="mycert.pem"
  100.      * @command-example --Name="phptest"
  101.      */
  102.     public function getPropertiesCommand($subscriptionId$certificate$certificatePassphrase$serviceName)
  103.     {
  104.         $client new Microsoft_WindowsAzure_Management_Client($subscriptionId$certificate$certificatePassphrase);
  105.         $result $client->getHostedServiceProperties($serviceName);
  106.         
  107.         $this->_displayObjectInformation($resultarray('ServiceName''Label''AffinityGroup''Location'));
  108.     }
  109.     
  110.     /**
  111.      * Get hosted service account property.
  112.      * 
  113.      * @command-name GetProperty
  114.      * @command-description Get storage account property.
  115.      * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
  116.      * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
  117.      * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
  118.      * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env|Microsoft_Console_Command_ParameterSource_StdIn --Name Required. The hosted service DNS name to operate on.
  119.      * @command-parameter-for $property Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Property|-prop Required. The property to retrieve for the hosted service account.
  120.      * @command-example Get hosted service account property "Url" for service "phptest":
  121.      * @command-example GetProperty -sid="<your_subscription_id>" -cert="mycert.pem"
  122.      * @command-example --Name="phptest" --Property=Url
  123.      */
  124.     public function getPropertyCommand($subscriptionId$certificate$certificatePassphrase$serviceName$property)
  125.     {
  126.         $client new Microsoft_WindowsAzure_Management_Client($subscriptionId$certificate$certificatePassphrase);
  127.         $result $client->getHostedServiceProperties($serviceName);
  128.         
  129.         echo $result->$property;
  130.     }
  131.     
  132.     /**
  133.      * Create hosted service account.
  134.      * 
  135.      * @command-name Create
  136.      * @command-description Create hosted service account.
  137.      * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
  138.      * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
  139.      * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
  140.      * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Name Required. The hosted service DNS name.
  141.      * @command-parameter-for $label Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Label Required. A label for the hosted service.
  142.      * @command-parameter-for $description Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Description Optional. A description for the hosted service.
  143.      * @command-parameter-for $location Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Location Required if AffinityGroup is not specified. The location where the hosted service will be created.
  144.      * @command-parameter-for $affinityGroup Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --AffinityGroup Required if Location is not specified. The name of an existing affinity group associated with this subscription.
  145.      * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
  146.      * @command-example Create hosted service account in West Europe
  147.      * @command-example Create -p="phpazure" --Name="phptestsdk2" --Label="phptestsdk2" --Location="West Europe"
  148.      */
  149.     public function createCommand($subscriptionId$certificate$certificatePassphrase$serviceName$label$description$location$affinityGroup$waitForOperation false)
  150.     {
  151.         $client new Microsoft_WindowsAzure_Management_Client($subscriptionId$certificate$certificatePassphrase);
  152.         $client->createHostedService($serviceName$label$description$location$affinityGroup);
  153.         if ($waitForOperation{
  154.             $client->waitForOperation();
  155.         }
  156.         echo $serviceName;
  157.     }
  158.     
  159.     /**
  160.      * Update hosted service account.
  161.      * 
  162.      * @command-name Update
  163.      * @command-description Update hosted service account.
  164.      * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
  165.      * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
  166.      * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
  167.      * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_StdIn --Name Required. The hosted service DNS name.
  168.      * @command-parameter-for $label Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Label Required. A label for the hosted service.
  169.      * @command-parameter-for $description Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Description Optional. A description for the hosted service.
  170.      * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
  171.      * @command-example Update hosted service
  172.      * @command-example Update -p="phpazure" --Name="phptestsdk2" --Label="New label" --Description="Some description"
  173.      */
  174.     public function updateCommand($subscriptionId$certificate$certificatePassphrase$serviceName$label$description$waitForOperation false)
  175.     {
  176.         $client new Microsoft_WindowsAzure_Management_Client($subscriptionId$certificate$certificatePassphrase);
  177.         $client->updateHostedService($serviceName$label$description);
  178.         if ($waitForOperation{
  179.             $client->waitForOperation();
  180.         }
  181.         echo $serviceName;
  182.     }
  183.     
  184.     /**
  185.      * Delete hosted service account.
  186.      * 
  187.      * @command-name Delete
  188.      * @command-description Delete hosted service account.
  189.      * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
  190.      * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
  191.      * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
  192.      * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_StdIn --Name Required. The hosted service DNS name.
  193.      * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
  194.      * @command-example Delete hosted service
  195.      * @command-example Delete -p="phpazure" --Name="phptestsdk2"
  196.      */
  197.     public function deleteCommand($subscriptionId$certificate$certificatePassphrase$serviceName$waitForOperation false)
  198.     {
  199.         $client new Microsoft_WindowsAzure_Management_Client($subscriptionId$certificate$certificatePassphrase);
  200.         $client->deleteHostedService($serviceName);
  201.         if ($waitForOperation{
  202.             $client->waitForOperation();
  203.         }
  204.         echo $serviceName;
  205.     }
  206. }
  207.  

Documentation generated on Sat, 03 Dec 2011 13:59:36 +0100 by phpDocumentor 1.4.3