Overview

Namespaces

  • OpenCloud
    • Autoscale
      • Resource
    • CloudMonitoring
      • Exception
      • Resource
    • Common
      • Collection
      • Constants
      • Exceptions
      • Http
        • Message
      • Log
      • Resource
      • Service
    • Compute
      • Constants
      • Exception
      • Resource
    • Database
      • Resource
    • DNS
      • Collection
      • Resource
    • Identity
      • Constants
      • Resource
    • Image
      • Enum
      • Resource
        • JsonPatch
        • Schema
    • LoadBalancer
      • Enum
      • 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:  * Copyright 2012-2014 Rackspace US, Inc.
  4:  *
  5:  * Licensed under the Apache License, Version 2.0 (the "License");
  6:  * you may not use this file except in compliance with the License.
  7:  * You may obtain a copy of the License at
  8:  *
  9:  * http://www.apache.org/licenses/LICENSE-2.0
 10:  *
 11:  * Unless required by applicable law or agreed to in writing, software
 12:  * distributed under the License is distributed on an "AS IS" BASIS,
 13:  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14:  * See the License for the specific language governing permissions and
 15:  * limitations under the License.
 16:  */
 17: 
 18: namespace OpenCloud\Orchestration;
 19: 
 20: use OpenCloud\Common\PersistentObject;
 21: use OpenCloud\Exceptions\CreateError;
 22: 
 23: /**
 24:  * The Stack class requires a CloudFormation template and may contain additional
 25:  * parameters for that template.
 26:  *
 27:  * A Stack is always associated with an (Orchestration) Service.
 28:  *
 29:  * @codeCoverageIgnore
 30:  */
 31: class Stack extends PersistentObject
 32: {
 33:     /**
 34:      * Identifier of stack.
 35:      *
 36:      * @var string
 37:      */
 38:     protected $id;
 39: 
 40:     /**
 41:      * The name associated with the stack. Must be unique within your account,
 42:      * contain only alphanumeric characters (case sensitive) and start with an
 43:      * alpha character. Maximum length of the name is 255 characters.
 44:      *
 45:      * @var string
 46:      */
 47:     protected $stack_name;
 48: 
 49:     /**
 50:      * A list of Parameter structures that specify input parameters for the stack.
 51:      *
 52:      * @var mixed
 53:      */
 54:     protected $parameters;
 55: 
 56:     /**
 57:      * Structure containing the template body.
 58:      *
 59:      * @var string
 60:      */
 61:     protected $template;
 62: 
 63:     /**
 64:      * Set to true to disable rollback of the stack if stack creation failed.
 65:      *
 66:      * @var bool
 67:      */
 68:     protected $disable_rollback;
 69: 
 70:     /**
 71:      * Description of stack.
 72:      *
 73:      * @var string
 74:      */
 75:     protected $description;
 76: 
 77:     /**
 78:      * @var type
 79:      */
 80:     protected $stack_status_reason;
 81: 
 82:     /**
 83:      * @var type
 84:      */
 85:     protected $outputs;
 86: 
 87:     /**
 88:      * @var type
 89:      */
 90:     protected $creation_time;
 91: 
 92:     /**
 93:      * Array of stack lists.
 94:      *
 95:      * @var array
 96:      */
 97:     protected $links;
 98: 
 99:     /**
100:      * The list of capabilities that you want to allow in the stack.
101:      *
102:      * @var mixed
103:      */
104:     protected $capabilities;
105: 
106:     /**
107:      * The Simple Notification Service topic ARNs to publish stack related events.
108:      *
109:      * @var mixed
110:      */
111:     protected $notification_topics;
112: 
113:     /**
114:      * The amount of time that can pass before the stack status becomes
115:      * CREATE_FAILED; if DisableRollback is not set or is set to false, the
116:      * stack will be rolled back.
117:      *
118:      * @var string
119:      */
120:     protected $timeout_mins;
121: 
122:     /**
123:      * @var type
124:      */
125:     protected $stack_status;
126: 
127:     /**
128:      * @var type
129:      */
130:     protected $updated_time;
131: 
132:     /**
133:      * @var type
134:      */
135:     protected $template_description;
136: 
137:     protected static $json_name = "stack";
138:     protected static $url_resource = "stacks";
139:     protected $createKeys = array(
140:         'template',
141:         'stack_name'
142:     );
143: 
144:     /**
145:      * {@inheritDoc}
146:      */
147:     protected function createJson()
148:     {
149:         $pk = $this->primaryKeyField();
150: 
151:         if (!empty($this->{$pk})) {
152:             throw new CreateError(sprintf(
153:                 'Stack is already created and has ID of %s',
154:                 $this->$pk
155:             ));
156:         }
157: 
158:         $object = (object) array('disable_rollback' => false, 'timeout_mins' => 60);
159: 
160:         foreach ($this->createKeys as $property) {
161:             if (empty($this->$property)) {
162:                 throw new CreateError(sprintf(
163:                     'Cannot create Stack with null %s',
164:                     $property
165:                 ));
166:             } else {
167:                 $object->$property = $this->$property;
168:             }
169:         }
170: 
171:         if (null !== $this->parameters) {
172:             $object->parameters = $this->parameters;
173:         }
174: 
175:         return $object;
176:     }
177: 
178:     public function name()
179:     {
180:         return $this->stack_name;
181:     }
182: 
183:     public function status()
184:     {
185:         return $this->stack_status;
186:     }
187: 
188:     public function resource($id = null)
189:     {
190:         $resource = new Resource($this->getService());
191:         $resource->setParent($this);
192:         $resource->populate($id);
193: 
194:         return $resource;
195:     }
196: 
197:     public function resources()
198:     {
199:         return $this->getService()->collection(
200:             'OpenCloud\Orchestration\Resource',
201:             $this->url('resources'),
202:             $this
203:         );
204:     }
205: }
206: 
PHP OpenCloud API API documentation generated by ApiGen 2.8.0