Overview

Namespaces

  • OpenCloud
    • Autoscale
      • Resource
    • CloudMonitoring
      • Exception
      • Resource
    • Common
      • Collection
      • Constants
      • Exceptions
      • Http
        • Message
      • Identity
      • Log
      • Service
    • Compute
      • Constants
      • Exception
      • Resource
    • Database
      • Resource
    • DNS
      • Resource
    • LoadBalancer
      • Resource
    • ObjectStore
      • Constants
      • Exception
      • Resource
      • Upload
    • Orchestration
    • Queues
      • Exception
      • Resource
    • Volume
      • Resource
  • PHP

Classes

  • Resource
  • Service
  • Stack
  • Overview
  • Namespace
  • Class
  • Tree
  • Download
  1: <?php
  2: /**
  3:  * PHP OpenCloud library.
  4:  * 
  5:  * @copyright 2013 Rackspace Hosting, Inc. See LICENSE for information.
  6:  * @license   https://www.apache.org/licenses/LICENSE-2.0
  7:  * @author    Stephen Sugden <openstack@stephensugden.com>
  8:  */
  9: 
 10: namespace OpenCloud\Orchestration;
 11: 
 12: use OpenCloud\AbstractClass\PersistentObject;
 13: use OpenCloud\Exceptions\CreateError;
 14: 
 15: /**
 16:  * The Stack class requires a CloudFormation template and may contain additional
 17:  * parameters for that template.
 18:  *
 19:  * A Stack is always associated with an (Orchestration) Service.
 20:  * 
 21:  * @codeCoverageIgnore
 22:  */
 23: class Stack extends PersistentObject 
 24: {
 25:     /**
 26:      * Identifier of stack.
 27:      * 
 28:      * @var string 
 29:      */
 30:     protected $id;
 31:     
 32:     /**
 33:      * The name associated with the stack. Must be unique within your account, 
 34:      * contain only alphanumeric characters (case sensitive) and start with an 
 35:      * alpha character. Maximum length of the name is 255 characters.
 36:      * 
 37:      * @var string 
 38:      */
 39:     protected $stack_name;
 40:     
 41:     /**
 42:      * A list of Parameter structures that specify input parameters for the stack.
 43:      * 
 44:      * @var mixed 
 45:      */
 46:     protected $parameters;
 47:     
 48:     /**
 49:      * Structure containing the template body.
 50:      * 
 51:      * @var string
 52:      */
 53:     protected $template;
 54:     
 55:     /**
 56:      * Set to true to disable rollback of the stack if stack creation failed.
 57:      * 
 58:      * @var bool 
 59:      */
 60:     protected $disable_rollback;
 61:     
 62:     /**
 63:      * Description of stack.
 64:      * 
 65:      * @var string 
 66:      */
 67:     protected $description;
 68:     
 69:     /**
 70:      * @var type 
 71:      */
 72:     protected $stack_status_reason;
 73:     
 74:     /**
 75:      * @var type 
 76:      */
 77:     protected $outputs;
 78:     
 79:     /**
 80:      * @var type 
 81:      */
 82:     protected $creation_time;
 83:     
 84:     /**
 85:      * Array of stack lists.
 86:      * 
 87:      * @var array 
 88:      */
 89:     protected $links;
 90:     
 91:     /**
 92:      * The list of capabilities that you want to allow in the stack.
 93:      * 
 94:      * @var mixed 
 95:      */
 96:     protected $capabilities;
 97:     
 98:     /**
 99:      * The Simple Notification Service topic ARNs to publish stack related events.
100:      * 
101:      * @var mixed 
102:      */
103:     protected $notification_topics;
104:     
105:     /**
106:      * The amount of time that can pass before the stack status becomes 
107:      * CREATE_FAILED; if DisableRollback is not set or is set to false, the 
108:      * stack will be rolled back.
109:      * 
110:      * @var string 
111:      */
112:     protected $timeout_mins;
113:     
114:     /**
115:      * @var type
116:      */
117:     protected $stack_status;
118:     
119:     /**
120:      * @var type
121:      */
122:     protected $updated_time;
123:     
124:     /**
125:      * @var type
126:      */
127:     protected $template_description;
128:     
129:     protected static $json_name = "stack";
130:     protected static $url_resource = "stacks";
131:     protected $createKeys = array(
132:         'template', 
133:         'stack_name'
134:     );
135: 
136:     /**
137:      * {@inheritDoc}
138:      */
139:     protected function createJson() 
140:     {
141:         $pk = $this->primaryKeyField();
142:         
143:         if (!empty($this->{$pk})) {
144:             throw new CreateError(sprintf(
145:                 'Stack is already created and has ID of %s',
146:                 $this->$pk
147:             ));
148:         }
149: 
150:         $object = (object) array('disable_rollback' => false, 'timeout_mins' => 60);
151: 
152:         foreach ($this->createKeys as $property) {
153:             if (empty($this->$property)) {
154:                 throw new CreateError(sprintf(
155:                     'Cannot create Stack with null %s', 
156:                     $property
157:                 ));
158:             } else {
159:                 $object->$property = $this->$property;
160:             }
161:         }
162:         
163:         if (null !== $this->parameters) {
164:             $object->parameters = $this->parameters;
165:         }
166:         
167:         return $object;
168:     }
169: 
170:     public function name() 
171:     {
172:         return $this->stack_name;
173:     }
174: 
175:     public function status() 
176:     {
177:         return $this->stack_status;
178:     }
179: 
180:     public function resource($id = null) 
181:     {
182:         $resource = new Resource($this->getService());
183:         $resource->setParent($this);
184:         $resource->populate($id);
185:         return $resource;
186:     }
187: 
188:     public function resources() 
189:     {
190:         return $this->getService()->collection(
191:             'OpenCloud\Orchestration\Resource', 
192:             $this->url('resources'), 
193:             $this
194:         );
195:     }
196: }
197: 
PHP OpenCloud API API documentation generated by ApiGen 2.8.0