1: <?php
2:
3: namespace Saklient\Cloud\Models;
4:
5: require_once __DIR__ . "/../../../Saklient/Cloud/Client.php";
6: use \Saklient\Cloud\Client;
7: require_once __DIR__ . "/../../../Saklient/Cloud/Models/Model.php";
8: use \Saklient\Cloud\Models\Model;
9: require_once __DIR__ . "/../../../Saklient/Cloud/Resources/Resource.php";
10: use \Saklient\Cloud\Resources\Resource;
11: require_once __DIR__ . "/../../../Saklient/Cloud/Resources/ServerPlan.php";
12: use \Saklient\Cloud\Resources\ServerPlan;
13: require_once __DIR__ . "/../../../Saklient/Util.php";
14: use \Saklient\Util;
15: require_once __DIR__ . "/../../../Saklient/Errors/SaklientException.php";
16: use \Saklient\Errors\SaklientException;
17:
18:
19: class Model_ServerPlan extends Model {
20:
21: 22: 23: 24: 25: 26:
27: protected function _apiPath()
28: {
29: return "/product/server";
30: }
31:
32: 33: 34: 35: 36: 37:
38: protected function _rootKey()
39: {
40: return "ServerPlan";
41: }
42:
43: 44: 45: 46: 47: 48:
49: protected function _rootKeyM()
50: {
51: return "ServerPlans";
52: }
53:
54: 55: 56: 57: 58: 59:
60: protected function _className()
61: {
62: return "ServerPlan";
63: }
64:
65: 66: 67: 68: 69: 70: 71: 72:
73: protected function _createResourceImpl($obj, $wrapped=false)
74: {
75: Util::validateArgCount(func_num_args(), 1);
76: Util::validateType($wrapped, "boolean");
77: return new ServerPlan($this->_client, $obj, $wrapped);
78: }
79:
80: 81: 82: 83: 84: 85: 86:
87: public function offset($offset)
88: {
89: Util::validateArgCount(func_num_args(), 1);
90: Util::validateType($offset, "int");
91: return $this->_offset($offset);
92: }
93:
94: 95: 96: 97: 98: 99: 100:
101: public function limit($count)
102: {
103: Util::validateArgCount(func_num_args(), 1);
104: Util::validateType($count, "int");
105: return $this->_limit($count);
106: }
107:
108: 109: 110: 111: 112: 113: 114: 115: 116:
117: public function filterBy($key, $value, $multiple=false)
118: {
119: Util::validateArgCount(func_num_args(), 2);
120: Util::validateType($key, "string");
121: Util::validateType($multiple, "boolean");
122: return $this->_filterBy($key, $value, $multiple);
123: }
124:
125: 126: 127: 128: 129: 130:
131: public function reset()
132: {
133: return $this->_reset();
134: }
135:
136: 137: 138: 139: 140: 141: 142:
143: public function getById($id)
144: {
145: Util::validateArgCount(func_num_args(), 1);
146: Util::validateType($id, "string");
147: return $this->_getById($id);
148: }
149:
150: 151: 152: 153: 154: 155:
156: public function find()
157: {
158: return $this->_find();
159: }
160:
161: 162: 163: 164: 165:
166: public function __construct(\Saklient\Cloud\Client $client)
167: {
168: parent::__construct($client);
169: Util::validateArgCount(func_num_args(), 1);
170: Util::validateType($client, "\\Saklient\\Cloud\\Client");
171: }
172:
173: 174: 175: 176: 177: 178: 179: 180:
181: public function getBySpec($cores, $memoryGib)
182: {
183: Util::validateArgCount(func_num_args(), 2);
184: Util::validateType($cores, "int");
185: Util::validateType($memoryGib, "int");
186: $this->_filterBy("CPU", new \ArrayObject([$cores]));
187: $this->_filterBy("MemoryMB", new \ArrayObject([$memoryGib * 1024]));
188: return $this->_findOne();
189: }
190:
191:
192:
193: }
194:
195: