1
0

ModelBuildList.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. /**
  3. * This code was generated by
  4. * \ / _ _ _| _ _
  5. * | (_)\/(_)(_|\/| |(/_ v1.0.0
  6. * / /
  7. */
  8. namespace Twilio\Rest\Preview\Understand\Assistant;
  9. use Twilio\ListResource;
  10. use Twilio\Options;
  11. use Twilio\Values;
  12. use Twilio\Version;
  13. /**
  14. * PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
  15. */
  16. class ModelBuildList extends ListResource {
  17. /**
  18. * Construct the ModelBuildList
  19. *
  20. * @param Version $version Version that contains the resource
  21. * @param string $assistantSid The unique ID of the parent Assistant.
  22. * @return \Twilio\Rest\Preview\Understand\Assistant\ModelBuildList
  23. */
  24. public function __construct(Version $version, $assistantSid) {
  25. parent::__construct($version);
  26. // Path Solution
  27. $this->solution = array('assistantSid' => $assistantSid, );
  28. $this->uri = '/Assistants/' . rawurlencode($assistantSid) . '/ModelBuilds';
  29. }
  30. /**
  31. * Streams ModelBuildInstance records from the API as a generator stream.
  32. * This operation lazily loads records as efficiently as possible until the
  33. * limit
  34. * is reached.
  35. * The results are returned as a generator, so this operation is memory
  36. * efficient.
  37. *
  38. * @param int $limit Upper limit for the number of records to return. stream()
  39. * guarantees to never return more than limit. Default is no
  40. * limit
  41. * @param mixed $pageSize Number of records to fetch per request, when not set
  42. * will use the default value of 50 records. If no
  43. * page_size is defined but a limit is defined, stream()
  44. * will attempt to read the limit with the most
  45. * efficient page size, i.e. min(limit, 1000)
  46. * @return \Twilio\Stream stream of results
  47. */
  48. public function stream($limit = null, $pageSize = null) {
  49. $limits = $this->version->readLimits($limit, $pageSize);
  50. $page = $this->page($limits['pageSize']);
  51. return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
  52. }
  53. /**
  54. * Reads ModelBuildInstance records from the API as a list.
  55. * Unlike stream(), this operation is eager and will load `limit` records into
  56. * memory before returning.
  57. *
  58. * @param int $limit Upper limit for the number of records to return. read()
  59. * guarantees to never return more than limit. Default is no
  60. * limit
  61. * @param mixed $pageSize Number of records to fetch per request, when not set
  62. * will use the default value of 50 records. If no
  63. * page_size is defined but a limit is defined, read()
  64. * will attempt to read the limit with the most
  65. * efficient page size, i.e. min(limit, 1000)
  66. * @return ModelBuildInstance[] Array of results
  67. */
  68. public function read($limit = null, $pageSize = null) {
  69. return iterator_to_array($this->stream($limit, $pageSize), false);
  70. }
  71. /**
  72. * Retrieve a single page of ModelBuildInstance records from the API.
  73. * Request is executed immediately
  74. *
  75. * @param mixed $pageSize Number of records to return, defaults to 50
  76. * @param string $pageToken PageToken provided by the API
  77. * @param mixed $pageNumber Page Number, this value is simply for client state
  78. * @return \Twilio\Page Page of ModelBuildInstance
  79. */
  80. public function page($pageSize = Values::NONE, $pageToken = Values::NONE, $pageNumber = Values::NONE) {
  81. $params = Values::of(array(
  82. 'PageToken' => $pageToken,
  83. 'Page' => $pageNumber,
  84. 'PageSize' => $pageSize,
  85. ));
  86. $response = $this->version->page(
  87. 'GET',
  88. $this->uri,
  89. $params
  90. );
  91. return new ModelBuildPage($this->version, $response, $this->solution);
  92. }
  93. /**
  94. * Retrieve a specific page of ModelBuildInstance records from the API.
  95. * Request is executed immediately
  96. *
  97. * @param string $targetUrl API-generated URL for the requested results page
  98. * @return \Twilio\Page Page of ModelBuildInstance
  99. */
  100. public function getPage($targetUrl) {
  101. $response = $this->version->getDomain()->getClient()->request(
  102. 'GET',
  103. $targetUrl
  104. );
  105. return new ModelBuildPage($this->version, $response, $this->solution);
  106. }
  107. /**
  108. * Create a new ModelBuildInstance
  109. *
  110. * @param array|Options $options Optional Arguments
  111. * @return ModelBuildInstance Newly created ModelBuildInstance
  112. * @throws TwilioException When an HTTP error occurs.
  113. */
  114. public function create($options = array()) {
  115. $options = new Values($options);
  116. $data = Values::of(array(
  117. 'StatusCallback' => $options['statusCallback'],
  118. 'UniqueName' => $options['uniqueName'],
  119. ));
  120. $payload = $this->version->create(
  121. 'POST',
  122. $this->uri,
  123. array(),
  124. $data
  125. );
  126. return new ModelBuildInstance($this->version, $payload, $this->solution['assistantSid']);
  127. }
  128. /**
  129. * Constructs a ModelBuildContext
  130. *
  131. * @param string $sid The sid
  132. * @return \Twilio\Rest\Preview\Understand\Assistant\ModelBuildContext
  133. */
  134. public function getContext($sid) {
  135. return new ModelBuildContext($this->version, $this->solution['assistantSid'], $sid);
  136. }
  137. /**
  138. * Provide a friendly representation
  139. *
  140. * @return string Machine friendly representation
  141. */
  142. public function __toString() {
  143. return '[Twilio.Preview.Understand.ModelBuildList]';
  144. }
  145. }