BehaviorCollectionService.php 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <?php
  2. namespace OpenSearch\Generated\BehaviorCollection;
  3. /**
  4. * Autogenerated by Thrift Compiler (0.9.3)
  5. *
  6. * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  7. * @generated
  8. */
  9. use Thrift\Base\TBase;
  10. use Thrift\Type\TType;
  11. use Thrift\Type\TMessageType;
  12. use Thrift\Exception\TException;
  13. use Thrift\Exception\TProtocolException;
  14. use Thrift\Protocol\TProtocol;
  15. use Thrift\Protocol\TBinaryProtocolAccelerated;
  16. use Thrift\Exception\TApplicationException;
  17. interface BehaviorCollectionServiceIf {
  18. /**
  19. * @param string $recordsJson
  20. * @param string $searchAppName
  21. * @param string $behaviorCollectionName
  22. * @return \OpenSearch\Generated\Common\OpenSearchResult
  23. * @throws \OpenSearch\Generated\Common\OpenSearchException
  24. * @throws \OpenSearch\Generated\Common\OpenSearchClientException
  25. */
  26. public function push($recordsJson, $searchAppName, $behaviorCollectionName);
  27. }
  28. class BehaviorCollectionServiceClient implements \OpenSearch\Generated\BehaviorCollection\BehaviorCollectionServiceIf {
  29. protected $input_ = null;
  30. protected $output_ = null;
  31. protected $seqid_ = 0;
  32. public function __construct($input, $output=null) {
  33. $this->input_ = $input;
  34. $this->output_ = $output ? $output : $input;
  35. }
  36. public function push($recordsJson, $searchAppName, $behaviorCollectionName)
  37. {
  38. $this->send_push($recordsJson, $searchAppName, $behaviorCollectionName);
  39. return $this->recv_push();
  40. }
  41. public function send_push($recordsJson, $searchAppName, $behaviorCollectionName)
  42. {
  43. $args = new \BehaviorCollectionService_push_args();
  44. $args->recordsJson = $recordsJson;
  45. $args->searchAppName = $searchAppName;
  46. $args->behaviorCollectionName = $behaviorCollectionName;
  47. $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');
  48. if ($bin_accel)
  49. {
  50. thrift_protocol_write_binary($this->output_, 'push', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite());
  51. }
  52. else
  53. {
  54. $this->output_->writeMessageBegin('push', TMessageType::CALL, $this->seqid_);
  55. $args->write($this->output_);
  56. $this->output_->writeMessageEnd();
  57. $this->output_->getTransport()->flush();
  58. }
  59. }
  60. public function recv_push()
  61. {
  62. $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary');
  63. if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\BehaviorCollectionService_push_result', $this->input_->isStrictRead());
  64. else
  65. {
  66. $rseqid = 0;
  67. $fname = null;
  68. $mtype = 0;
  69. $this->input_->readMessageBegin($fname, $mtype, $rseqid);
  70. if ($mtype == TMessageType::EXCEPTION) {
  71. $x = new TApplicationException();
  72. $x->read($this->input_);
  73. $this->input_->readMessageEnd();
  74. throw $x;
  75. }
  76. $result = new \BehaviorCollectionService_push_result();
  77. $result->read($this->input_);
  78. $this->input_->readMessageEnd();
  79. }
  80. if ($result->success !== null) {
  81. return $result->success;
  82. }
  83. if ($result->error !== null) {
  84. throw $result->error;
  85. }
  86. if ($result->e !== null) {
  87. throw $result->e;
  88. }
  89. throw new \Exception("push failed: unknown result");
  90. }
  91. }
  92. // HELPER FUNCTIONS AND STRUCTURES
  93. class BehaviorCollectionService_push_args {
  94. static $_TSPEC;
  95. /**
  96. * @var string
  97. */
  98. public $recordsJson = null;
  99. /**
  100. * @var string
  101. */
  102. public $searchAppName = null;
  103. /**
  104. * @var string
  105. */
  106. public $behaviorCollectionName = null;
  107. public function __construct($vals=null) {
  108. if (!isset(self::$_TSPEC)) {
  109. self::$_TSPEC = array(
  110. 1 => array(
  111. 'var' => 'recordsJson',
  112. 'type' => TType::STRING,
  113. ),
  114. 2 => array(
  115. 'var' => 'searchAppName',
  116. 'type' => TType::STRING,
  117. ),
  118. 3 => array(
  119. 'var' => 'behaviorCollectionName',
  120. 'type' => TType::STRING,
  121. ),
  122. );
  123. }
  124. if (is_array($vals)) {
  125. if (isset($vals['recordsJson'])) {
  126. $this->recordsJson = $vals['recordsJson'];
  127. }
  128. if (isset($vals['searchAppName'])) {
  129. $this->searchAppName = $vals['searchAppName'];
  130. }
  131. if (isset($vals['behaviorCollectionName'])) {
  132. $this->behaviorCollectionName = $vals['behaviorCollectionName'];
  133. }
  134. }
  135. }
  136. public function getName() {
  137. return 'BehaviorCollectionService_push_args';
  138. }
  139. public function read($input)
  140. {
  141. $xfer = 0;
  142. $fname = null;
  143. $ftype = 0;
  144. $fid = 0;
  145. $xfer += $input->readStructBegin($fname);
  146. while (true)
  147. {
  148. $xfer += $input->readFieldBegin($fname, $ftype, $fid);
  149. if ($ftype == TType::STOP) {
  150. break;
  151. }
  152. switch ($fid)
  153. {
  154. case 1:
  155. if ($ftype == TType::STRING) {
  156. $xfer += $input->readString($this->recordsJson);
  157. } else {
  158. $xfer += $input->skip($ftype);
  159. }
  160. break;
  161. case 2:
  162. if ($ftype == TType::STRING) {
  163. $xfer += $input->readString($this->searchAppName);
  164. } else {
  165. $xfer += $input->skip($ftype);
  166. }
  167. break;
  168. case 3:
  169. if ($ftype == TType::STRING) {
  170. $xfer += $input->readString($this->behaviorCollectionName);
  171. } else {
  172. $xfer += $input->skip($ftype);
  173. }
  174. break;
  175. default:
  176. $xfer += $input->skip($ftype);
  177. break;
  178. }
  179. $xfer += $input->readFieldEnd();
  180. }
  181. $xfer += $input->readStructEnd();
  182. return $xfer;
  183. }
  184. public function write($output) {
  185. $xfer = 0;
  186. $xfer += $output->writeStructBegin('BehaviorCollectionService_push_args');
  187. if ($this->recordsJson !== null) {
  188. $xfer += $output->writeFieldBegin('recordsJson', TType::STRING, 1);
  189. $xfer += $output->writeString($this->recordsJson);
  190. $xfer += $output->writeFieldEnd();
  191. }
  192. if ($this->searchAppName !== null) {
  193. $xfer += $output->writeFieldBegin('searchAppName', TType::STRING, 2);
  194. $xfer += $output->writeString($this->searchAppName);
  195. $xfer += $output->writeFieldEnd();
  196. }
  197. if ($this->behaviorCollectionName !== null) {
  198. $xfer += $output->writeFieldBegin('behaviorCollectionName', TType::STRING, 3);
  199. $xfer += $output->writeString($this->behaviorCollectionName);
  200. $xfer += $output->writeFieldEnd();
  201. }
  202. $xfer += $output->writeFieldStop();
  203. $xfer += $output->writeStructEnd();
  204. return $xfer;
  205. }
  206. }
  207. class BehaviorCollectionService_push_result {
  208. static $_TSPEC;
  209. /**
  210. * @var \Generated\Common\OpenSearchResult
  211. */
  212. public $success = null;
  213. /**
  214. * @var \Generated\Common\OpenSearchException
  215. */
  216. public $error = null;
  217. /**
  218. * @var \Generated\Common\OpenSearchClientException
  219. */
  220. public $e = null;
  221. public function __construct($vals=null) {
  222. if (!isset(self::$_TSPEC)) {
  223. self::$_TSPEC = array(
  224. 0 => array(
  225. 'var' => 'success',
  226. 'type' => TType::STRUCT,
  227. 'class' => '\Generated\Common\OpenSearchResult',
  228. ),
  229. 1 => array(
  230. 'var' => 'error',
  231. 'type' => TType::STRUCT,
  232. 'class' => '\Generated\Common\OpenSearchException',
  233. ),
  234. 2 => array(
  235. 'var' => 'e',
  236. 'type' => TType::STRUCT,
  237. 'class' => '\Generated\Common\OpenSearchClientException',
  238. ),
  239. );
  240. }
  241. if (is_array($vals)) {
  242. if (isset($vals['success'])) {
  243. $this->success = $vals['success'];
  244. }
  245. if (isset($vals['error'])) {
  246. $this->error = $vals['error'];
  247. }
  248. if (isset($vals['e'])) {
  249. $this->e = $vals['e'];
  250. }
  251. }
  252. }
  253. public function getName() {
  254. return 'BehaviorCollectionService_push_result';
  255. }
  256. public function read($input)
  257. {
  258. $xfer = 0;
  259. $fname = null;
  260. $ftype = 0;
  261. $fid = 0;
  262. $xfer += $input->readStructBegin($fname);
  263. while (true)
  264. {
  265. $xfer += $input->readFieldBegin($fname, $ftype, $fid);
  266. if ($ftype == TType::STOP) {
  267. break;
  268. }
  269. switch ($fid)
  270. {
  271. case 0:
  272. if ($ftype == TType::STRUCT) {
  273. $this->success = new \Generated\Common\OpenSearchResult();
  274. $xfer += $this->success->read($input);
  275. } else {
  276. $xfer += $input->skip($ftype);
  277. }
  278. break;
  279. case 1:
  280. if ($ftype == TType::STRUCT) {
  281. $this->error = new \Generated\Common\OpenSearchException();
  282. $xfer += $this->error->read($input);
  283. } else {
  284. $xfer += $input->skip($ftype);
  285. }
  286. break;
  287. case 2:
  288. if ($ftype == TType::STRUCT) {
  289. $this->e = new \Generated\Common\OpenSearchClientException();
  290. $xfer += $this->e->read($input);
  291. } else {
  292. $xfer += $input->skip($ftype);
  293. }
  294. break;
  295. default:
  296. $xfer += $input->skip($ftype);
  297. break;
  298. }
  299. $xfer += $input->readFieldEnd();
  300. }
  301. $xfer += $input->readStructEnd();
  302. return $xfer;
  303. }
  304. public function write($output) {
  305. $xfer = 0;
  306. $xfer += $output->writeStructBegin('BehaviorCollectionService_push_result');
  307. if ($this->success !== null) {
  308. if (!is_object($this->success)) {
  309. throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
  310. }
  311. $xfer += $output->writeFieldBegin('success', TType::STRUCT, 0);
  312. $xfer += $this->success->write($output);
  313. $xfer += $output->writeFieldEnd();
  314. }
  315. if ($this->error !== null) {
  316. $xfer += $output->writeFieldBegin('error', TType::STRUCT, 1);
  317. $xfer += $this->error->write($output);
  318. $xfer += $output->writeFieldEnd();
  319. }
  320. if ($this->e !== null) {
  321. $xfer += $output->writeFieldBegin('e', TType::STRUCT, 2);
  322. $xfer += $this->e->write($output);
  323. $xfer += $output->writeFieldEnd();
  324. }
  325. $xfer += $output->writeFieldStop();
  326. $xfer += $output->writeStructEnd();
  327. return $xfer;
  328. }
  329. }