/vendor/twilio/sdk/src/Twilio/Rest/Supersim/V1/NetworkAccessProfile/NetworkAccessProfileNetworkList.php

https://gitlab.com/D-apos-software/Alcesac · PHP · 162 lines · 53 code · 20 blank · 89 comment · 0 complexity · 6418275bc0e96fd1f235aa8b0eefea14 MD5 · raw file

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