Class: Twilio::REST::Video::V1::RoomList

Inherits:
ListResource show all
Defined in:
lib/twilio-ruby/rest/video/v1/room.rb

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ RoomList

Initialize the RoomList

Parameters:

  • Version that contains the resource



18
19
20
21
22
23
24
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 18

def initialize(version)
  super(version)

  # Path Solution
  @solution = {}
  @uri = "/Rooms"
end

Instance Method Details

#create(enable_turn: :unset, type: :unset, unique_name: :unset, status_callback: :unset, status_callback_method: :unset, max_participants: :unset, record_participants_on_connect: :unset, video_codecs: :unset, media_region: :unset) ⇒ RoomInstance

Retrieve a single page of RoomInstance records from the API. Request is executed immediately.

Parameters:

  • (defaults to: :unset)

    Deprecated. Enable [Twilio’s Network Traversal TURN service](www.twilio.com/stun-turn). TURN service is used when direct peer-to-peer media connections cannot be established due to firewall restrictions. This setting only applies to Rooms with type ‘peer-to-peer`.

  • (defaults to: :unset)

    Type of room, either ‘peer-to-peer`, `group-small` or `group`. Will be `group` by default.

  • (defaults to: :unset)

    Name of the Room. This is unique for ‘in-progress` rooms. If not provided, Room name will be set to the Room Sid.

  • (defaults to: :unset)

    A URL that Twilio sends asynchronous webhook requests to on every room event. If not provided, status callback events will not be dispatched.

  • (defaults to: :unset)

    HTTP method Twilio should use when requesting the above URL. Defaults to ‘POST`.

  • (defaults to: :unset)

    Maximum number of Participants in the Room. Peer-to-peer rooms can have a maximum of 10 Participants. Small Group rooms can have a max of 4 Participants. Group rooms can have a max of 50 Participants

  • (defaults to: :unset)

    Start Participant recording when connected. ***This feature is not available in ‘peer-to-peer` rooms.***

  • (defaults to: :unset)

    An array of video codecs supported when publishing a Track in the Room. ‘VP8` and `H264` codecs are supported. ***This feature is not available in `peer-to-peer` rooms***

  • (defaults to: :unset)

    Region for the media server in Group Rooms. Default region is ‘us1`. See the list of [available Media Regions.](www.twilio.com/docs/api/video/ip-address-whitelisting#group-rooms-media-servers)***This feature is not available in `peer-to-peer` rooms.***

Returns:

  • Newly created RoomInstance



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 54

def create(enable_turn: :unset, type: :unset, unique_name: :unset, status_callback: :unset, status_callback_method: :unset, max_participants: :unset, record_participants_on_connect: :unset, video_codecs: :unset, media_region: :unset)
  data = Twilio::Values.of({
      'EnableTurn' => enable_turn,
      'Type' => type,
      'UniqueName' => unique_name,
      'StatusCallback' => status_callback,
      'StatusCallbackMethod' => status_callback_method,
      'MaxParticipants' => max_participants,
      'RecordParticipantsOnConnect' => record_participants_on_connect,
      'VideoCodecs' => Twilio.serialize_list(video_codecs) { |e| e },
      'MediaRegion' => media_region,
  })

  payload = @version.create(
      'POST',
      @uri,
      data: data
  )

  RoomInstance.new(@version, payload, )
end

#eachObject

When passed a block, yields RoomInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.



141
142
143
144
145
146
147
148
149
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 141

def each
  limits = @version.read_limits

  page = self.page(page_size: limits[:page_size], )

  @version.stream(page,
                  limit: limits[:limit],
                  page_limit: limits[:page_limit]).each {|x| yield x}
end

#get_page(target_url) ⇒ Page

Retrieve a single page of RoomInstance records from the API. Request is executed immediately.

Parameters:

  • API-generated URL for the requested results page

Returns:

  • Page of RoomInstance



188
189
190
191
192
193
194
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 188

def get_page(target_url)
  response = @version.domain.request(
      'GET',
      target_url
  )
  RoomPage.new(@version, response, @solution)
end

#list(status: :unset, unique_name: :unset, date_created_after: :unset, date_created_before: :unset, limit: nil, page_size: nil) ⇒ Array

Lists RoomInstance records from the API as a list. Unlike stream(), this operation is eager and will load ‘limit` records into memory before returning.

Parameters:

  • (defaults to: :unset)

    Only show Rooms with the given status: ‘in-progress` (default), or `completed`

  • (defaults to: :unset)

    Only show Rooms with the provided Name.

  • (defaults to: :unset)

    Only show Rooms that started on or after this date, given as ‘YYYY-MM-DD`.

  • (defaults to: :unset)

    Only show Rooms that started before this date, given as ‘YYYY-MM-DD`.

  • (defaults to: nil)

    Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit

  • (defaults to: nil)

    Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)

Returns:

  • Array of up to limit results



94
95
96
97
98
99
100
101
102
103
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 94

def list(status: :unset, unique_name: :unset, date_created_after: :unset, date_created_before: :unset, limit: nil, page_size: nil)
  self.stream(
      status: status,
      unique_name: unique_name,
      date_created_after: date_created_after,
      date_created_before: date_created_before,
      limit: limit,
      page_size: page_size
  ).entries
end

#page(status: :unset, unique_name: :unset, date_created_after: :unset, date_created_before: :unset, page_token: :unset, page_number: :unset, page_size: :unset) ⇒ Page

Retrieve a single page of RoomInstance records from the API. Request is executed immediately.

Parameters:

  • (defaults to: :unset)

    Only show Rooms with the given status: ‘in-progress` (default), or `completed`

  • (defaults to: :unset)

    Only show Rooms with the provided Name.

  • (defaults to: :unset)

    Only show Rooms that started on or after this date, given as ‘YYYY-MM-DD`.

  • (defaults to: :unset)

    Only show Rooms that started before this date, given as ‘YYYY-MM-DD`.

  • (defaults to: :unset)

    PageToken provided by the API

  • (defaults to: :unset)

    Page Number, this value is simply for client state

  • (defaults to: :unset)

    Number of records to return, defaults to 50

Returns:

  • Page of RoomInstance



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 165

def page(status: :unset, unique_name: :unset, date_created_after: :unset, date_created_before: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
  params = Twilio::Values.of({
      'Status' => status,
      'UniqueName' => unique_name,
      'DateCreatedAfter' => Twilio.serialize_iso8601_datetime(date_created_after),
      'DateCreatedBefore' => Twilio.serialize_iso8601_datetime(date_created_before),
      'PageToken' => page_token,
      'Page' => page_number,
      'PageSize' => page_size,
  })
  response = @version.page(
      'GET',
      @uri,
      params
  )
  RoomPage.new(@version, response, @solution)
end

#stream(status: :unset, unique_name: :unset, date_created_after: :unset, date_created_before: :unset, limit: nil, page_size: nil) ⇒ Enumerable

Streams RoomInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached.

Parameters:

  • (defaults to: :unset)

    Only show Rooms with the given status: ‘in-progress` (default), or `completed`

  • (defaults to: :unset)

    Only show Rooms with the provided Name.

  • (defaults to: :unset)

    Only show Rooms that started on or after this date, given as ‘YYYY-MM-DD`.

  • (defaults to: :unset)

    Only show Rooms that started before this date, given as ‘YYYY-MM-DD`.

  • (defaults to: nil)

    Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit.

  • (defaults to: nil)

    Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)

Returns:

  • Enumerable that will yield up to limit results



123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 123

def stream(status: :unset, unique_name: :unset, date_created_after: :unset, date_created_before: :unset, limit: nil, page_size: nil)
  limits = @version.read_limits(limit, page_size)

  page = self.page(
      status: status,
      unique_name: unique_name,
      date_created_after: date_created_after,
      date_created_before: date_created_before,
      page_size: limits[:page_size],
  )

  @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
end

#to_sObject

Provide a user friendly representation



198
199
200
# File 'lib/twilio-ruby/rest/video/v1/room.rb', line 198

def to_s
  '#<Twilio.Video.V1.RoomList>'
end