PageRenderTime 40ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/src/ServiceManagement/Models/RoleInstance.php

http://github.com/WindowsAzure/azure-sdk-for-php
PHP | 329 lines | 124 code | 30 blank | 175 comment | 0 complexity | 756e0cfb9551569a4f8adca4a716e4de MD5 | raw file
  1. <?php
  2. /**
  3. * LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. * http://www.apache.org/licenses/LICENSE-2.0.
  7. *
  8. * Unless required by applicable law or agreed to in writing, software
  9. * distributed under the License is distributed on an "AS IS" BASIS,
  10. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. * See the License for the specific language governing permissions and
  12. * limitations under the License.
  13. *
  14. * PHP version 5
  15. *
  16. * @category Microsoft
  17. *
  18. * @author Azure PHP SDK <azurephpsdk@microsoft.com>
  19. * @copyright 2012 Microsoft Corporation
  20. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  21. *
  22. * @link https://github.com/windowsazure/azure-sdk-for-php
  23. */
  24. namespace WindowsAzure\ServiceManagement\Models;
  25. use WindowsAzure\Common\Internal\Resources;
  26. use WindowsAzure\Common\Internal\Utilities;
  27. /**
  28. * Represents a Windows Azure deployment role instance.
  29. *
  30. * @category Microsoft
  31. *
  32. * @author Azure PHP SDK <azurephpsdk@microsoft.com>
  33. * @copyright 2012 Microsoft Corporation
  34. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  35. *
  36. * @version Release: 0.5.0_2016-11
  37. *
  38. * @link https://github.com/windowsazure/azure-sdk-for-php
  39. */
  40. class RoleInstance
  41. {
  42. /**
  43. * @var string
  44. */
  45. private $_roleName;
  46. /**
  47. * @var string
  48. */
  49. private $_instanceName;
  50. /**
  51. * @var string
  52. */
  53. private $_instanceStatus;
  54. /**
  55. * @var int
  56. */
  57. private $_instanceUpgradeDomain;
  58. /**
  59. * @var int
  60. */
  61. private $_instanceFaultDomain;
  62. /**
  63. * @var string
  64. */
  65. private $_instanceSize;
  66. /**
  67. * @var string
  68. */
  69. private $_instanceStateDetails;
  70. /**
  71. * @var string
  72. */
  73. private $_instanceErrorCode;
  74. /**
  75. * Creates a new RoleInstance from parsed response body.
  76. *
  77. * @param array $parsed The parsed response body in array representation
  78. *
  79. * @return RoleInstance
  80. */
  81. public static function create($parsed)
  82. {
  83. $roleInstance = new self();
  84. $roleName = Utilities::tryGetValue(
  85. $parsed,
  86. Resources::XTAG_ROLE_NAME
  87. );
  88. $instanceName = Utilities::tryGetValue(
  89. $parsed,
  90. Resources::XTAG_INSTANCE_NAME
  91. );
  92. $instanceStatus = Utilities::tryGetValue(
  93. $parsed,
  94. Resources::XTAG_INSTANCE_STATUS
  95. );
  96. $instanceUpgradeDomain = Utilities::tryGetValue(
  97. $parsed,
  98. Resources::XTAG_INSTANCE_UPGRADE_DOMAIN
  99. );
  100. $instanceFaultDomain = Utilities::tryGetValue(
  101. $parsed,
  102. Resources::XTAG_INSTANCE_FAULT_DOMAIN
  103. );
  104. $instanceSize = Utilities::tryGetValue(
  105. $parsed,
  106. Resources::XTAG_INSTANCE_SIZE
  107. );
  108. $instanceStateDetails = Utilities::tryGetValue(
  109. $parsed,
  110. Resources::XTAG_INSTANCE_STATE_DETAILS
  111. );
  112. $instanceErrorCode = Utilities::tryGetValue(
  113. $parsed,
  114. Resources::XTAG_INSTANCE_ERROR_CODE
  115. );
  116. $roleInstance->setInstanceErrorCode($instanceErrorCode);
  117. $roleInstance->setInstanceFaultDomain(intval($instanceFaultDomain));
  118. $roleInstance->setInstanceName($instanceName);
  119. $roleInstance->setInstanceSize($instanceSize);
  120. $roleInstance->setInstanceStateDetails($instanceStateDetails);
  121. $roleInstance->setInstanceStatus($instanceStatus);
  122. $roleInstance->setInstanceUpgradeDomain(intval($instanceUpgradeDomain));
  123. $roleInstance->setRoleName($roleName);
  124. return $roleInstance;
  125. }
  126. /**
  127. * Gets the role name.
  128. *
  129. * The name of the role.
  130. *
  131. * @return string
  132. */
  133. public function getRoleName()
  134. {
  135. return $this->_roleName;
  136. }
  137. /**
  138. * Sets the role name.
  139. *
  140. * @param string $roleName The role name
  141. */
  142. public function setRoleName($roleName)
  143. {
  144. $this->_roleName = $roleName;
  145. }
  146. /**
  147. * Gets the instance name.
  148. *
  149. * The name of the specific role instance (if any).
  150. *
  151. * @return string
  152. */
  153. public function getInstanceName()
  154. {
  155. return $this->_instanceName;
  156. }
  157. /**
  158. * Sets the instance name.
  159. *
  160. * @param string $instanceName The instance name
  161. */
  162. public function setInstanceName($instanceName)
  163. {
  164. $this->_instanceName = $instanceName;
  165. }
  166. /**
  167. * Gets the instance status.
  168. *
  169. * The current status of this instance.
  170. *
  171. * @return string
  172. */
  173. public function getInstanceStatus()
  174. {
  175. return $this->_instanceStatus;
  176. }
  177. /**
  178. * Sets the instance status.
  179. *
  180. * @param string $instanceStatus The instance status
  181. */
  182. public function setInstanceStatus($instanceStatus)
  183. {
  184. $this->_instanceStatus = $instanceStatus;
  185. }
  186. /**
  187. * Gets the instance upgrade domain.
  188. *
  189. * The upgrade domain that this role instance belongs to. During an upgrade
  190. * deployment, all roles in the same upgrade domain are upgraded at the same
  191. * time.
  192. *
  193. * @return int
  194. */
  195. public function getInstanceUpgradeDomain()
  196. {
  197. return $this->_instanceUpgradeDomain;
  198. }
  199. /**
  200. * Sets the instance upgrade domain.
  201. *
  202. * @param int $instanceUpgradeDomain The instance upgrade domain
  203. */
  204. public function setInstanceUpgradeDomain($instanceUpgradeDomain)
  205. {
  206. $this->_instanceUpgradeDomain = $instanceUpgradeDomain;
  207. }
  208. /**
  209. * Gets the instance fault domain.
  210. *
  211. * The fault domain that this role instance belongs to. Role instances in the
  212. * same fault domain may be vulnerable to the failure of a single piece of
  213. * hardware.
  214. *
  215. * @return int
  216. */
  217. public function getInstanceFaultDomain()
  218. {
  219. return $this->_instanceFaultDomain;
  220. }
  221. /**
  222. * Sets the instance fault domain.
  223. *
  224. * @param int $instanceFaultDomain The instance fault domain
  225. */
  226. public function setInstanceFaultDomain($instanceFaultDomain)
  227. {
  228. $this->_instanceFaultDomain = $instanceFaultDomain;
  229. }
  230. /**
  231. * Gets the instance size.
  232. *
  233. * The size of the role instance. Possible values are: ExtraSmall, Small, Medium,
  234. * Large, ExtraLarge.
  235. *
  236. * @return string
  237. */
  238. public function getInstanceSize()
  239. {
  240. return $this->_instanceSize;
  241. }
  242. /**
  243. * Sets the instance size.
  244. *
  245. * @param string $instanceSize The instance size
  246. */
  247. public function setInstanceSize($instanceSize)
  248. {
  249. $this->_instanceSize = $instanceSize;
  250. }
  251. /**
  252. * Gets the instance state details.
  253. *
  254. * The instance state is returned as an English human-readable string that, when
  255. * present, provides a snapshot of the state of the virtual machine at the time
  256. * the operation was called. For example, when the instance is first being
  257. * initialized a "Preparing Windows for first use." could be returned.
  258. *
  259. * @return string
  260. */
  261. public function getInstanceStateDetails()
  262. {
  263. return $this->_instanceStateDetails;
  264. }
  265. /**
  266. * Sets the instance state details.
  267. *
  268. * @param string $instanceStateDetails The instance state details
  269. */
  270. public function setInstanceStateDetails($instanceStateDetails)
  271. {
  272. $this->_instanceStateDetails = $instanceStateDetails;
  273. }
  274. /**
  275. * Gets the instance error code.
  276. *
  277. * Error code of the latest role or VM start. For VMRoles the error codes are:
  278. * WaitTimeout, VhdTooLarge, AzureInternalError.
  279. *
  280. * For web and worker roles this field returns an error code that can be provided
  281. * to Windows Azure support to assist in resolution of errors. Typically this
  282. * field will be empty.
  283. *
  284. * @return string
  285. */
  286. public function getInstanceErrorCode()
  287. {
  288. return $this->_instanceErrorCode;
  289. }
  290. /**
  291. * Sets the instance error code.
  292. *
  293. * @param string $instanceErrorCode The instance error code
  294. */
  295. public function setInstanceErrorCode($instanceErrorCode)
  296. {
  297. $this->_instanceErrorCode = $instanceErrorCode;
  298. }
  299. }