## # This code was generated by # ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ # | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ # | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ # # Twilio - Video # This is the public Twilio REST API. # # NOTE: This class is auto generated by OpenAPI Generator. # https://openapi-generator.tech # Do not edit the class manually. # module Twilio module REST class Video < VideoBase class V1 < Version class RoomList < ListResource ## # Initialize the RoomList # @param [Version] version Version that contains the resource # @return [RoomList] RoomList def initialize(version) super(version) # Path Solution @solution = { } @uri = "/Rooms" end ## # Create the RoomInstance # @param [Boolean] enable_turn Deprecated, now always considered to be true. # @param [RoomType] type # @param [String] unique_name An application-defined string that uniquely identifies the resource. It can be used as a `room_sid` in place of the resource's `sid` in the URL to address the resource, assuming it does not contain any [reserved characters](https://tools.ietf.org/html/rfc3986#section-2.2) that would need to be URL encoded. This value is unique for `in-progress` rooms. SDK clients can use this name to connect to the room. REST API clients can use this name in place of the Room SID to interact with the room as long as the room is `in-progress`. # @param [String] status_callback The URL we should call using the `status_callback_method` to send status information to your application on every room event. See [Status Callbacks](https://www.twilio.com/docs/video/api/status-callbacks) for more info. # @param [String] status_callback_method The HTTP method we should use to call `status_callback`. Can be `POST` or `GET`. # @param [String] max_participants The maximum number of concurrent Participants allowed in the room. Peer-to-peer rooms can have up to 10 Participants. Small Group rooms can have up to 4 Participants. Group rooms can have up to 50 Participants. # @param [Boolean] record_participants_on_connect Whether to start recording when Participants connect. ***This feature is not available in `peer-to-peer` rooms.*** # @param [Array[VideoCodec]] video_codecs An array of the video codecs that are supported when publishing a track in the room. Can be: `VP8` and `H264`. ***This feature is not available in `peer-to-peer` rooms*** # @param [String] media_region The region for the media server in Group Rooms. Can be: one of the [available Media Regions](https://www.twilio.com/docs/video/ip-addresses#group-rooms-media-servers). ***This feature is not available in `peer-to-peer` rooms.*** # @param [Object] recording_rules A collection of Recording Rules that describe how to include or exclude matching tracks for recording # @param [Boolean] audio_only When set to true, indicates that the participants in the room will only publish audio. No video tracks will be allowed. Group rooms only. # @param [String] max_participant_duration The maximum number of seconds a Participant can be connected to the room. The maximum possible value is 86400 seconds (24 hours). The default is 14400 seconds (4 hours). # @param [String] empty_room_timeout Configures how long (in minutes) a room will remain active after last participant leaves. Valid values range from 1 to 60 minutes (no fractions). # @param [String] unused_room_timeout Configures how long (in minutes) a room will remain active if no one joins. Valid values range from 1 to 60 minutes (no fractions). # @param [Boolean] large_room When set to true, indicated that this is the large room. # @return [RoomInstance] Created RoomInstance 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, recording_rules: :unset, audio_only: :unset, max_participant_duration: :unset, empty_room_timeout: :unset, unused_room_timeout: :unset, large_room: :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, 'RecordingRules' => Twilio.serialize_object(recording_rules), 'AudioOnly' => audio_only, 'MaxParticipantDuration' => max_participant_duration, 'EmptyRoomTimeout' => empty_room_timeout, 'UnusedRoomTimeout' => unused_room_timeout, 'LargeRoom' => large_room, }) payload = @version.create('POST', @uri, data: data) RoomInstance.new( @version, payload, ) end ## # Lists RoomInstance records from the API as a list. # Unlike stream(), this operation is eager and will load `limit` records into # memory before returning. # @param [RoomStatus] status Read only the rooms with this status. Can be: `in-progress` (default) or `completed` # @param [String] unique_name Read only rooms with the this `unique_name`. # @param [Time] date_created_after Read only rooms that started on or after this date, given as `YYYY-MM-DD`. # @param [Time] date_created_before Read only rooms that started before this date, given as `YYYY-MM-DD`. # @param [Integer] limit Upper limit for the number of records to return. stream() # guarantees to never return more than limit. Default is no limit # @param [Integer] page_size 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) # @return [Array] Array of up to limit results 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 ## # Streams Instance records from the API as an Enumerable. # This operation lazily loads records as efficiently as possible until the limit # is reached. # @param [RoomStatus] status Read only the rooms with this status. Can be: `in-progress` (default) or `completed` # @param [String] unique_name Read only rooms with the this `unique_name`. # @param [Time] date_created_after Read only rooms that started on or after this date, given as `YYYY-MM-DD`. # @param [Time] date_created_before Read only rooms that started before this date, given as `YYYY-MM-DD`. # @param [Integer] limit Upper limit for the number of records to return. stream() # guarantees to never return more than limit. Default is no limit # @param [Integer] page_size 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) # @return [Enumerable] Enumerable that will yield up to limit results 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 ## # When passed a block, yields RoomInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit # is reached. 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 ## # Retrieve a single page of RoomInstance records from the API. # Request is executed immediately. # @param [RoomStatus] status Read only the rooms with this status. Can be: `in-progress` (default) or `completed` # @param [String] unique_name Read only rooms with the this `unique_name`. # @param [Time] date_created_after Read only rooms that started on or after this date, given as `YYYY-MM-DD`. # @param [Time] date_created_before Read only rooms that started before this date, given as `YYYY-MM-DD`. # @param [String] page_token PageToken provided by the API # @param [Integer] page_number Page Number, this value is simply for client state # @param [Integer] page_size Number of records to return, defaults to 50 # @return [Page] Page of RoomInstance 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: params) RoomPage.new(@version, response, @solution) end ## # Retrieve a single page of RoomInstance records from the API. # Request is executed immediately. # @param [String] target_url API-generated URL for the requested results page # @return [Page] Page of RoomInstance def get_page(target_url) response = @version.domain.request( 'GET', target_url ) RoomPage.new(@version, response, @solution) end # Provide a user friendly representation def to_s '#' end end class RoomContext < InstanceContext ## # Initialize the RoomContext # @param [Version] version Version that contains the resource # @param [String] sid The SID of the Room resource to update. # @return [RoomContext] RoomContext def initialize(version, sid) super(version) # Path Solution @solution = { sid: sid, } @uri = "/Rooms/#{@solution[:sid]}" # Dependents @recording_rules = nil @participants = nil @recordings = nil end ## # Fetch the RoomInstance # @return [RoomInstance] Fetched RoomInstance def fetch payload = @version.fetch('GET', @uri) RoomInstance.new( @version, payload, sid: @solution[:sid], ) end ## # Update the RoomInstance # @param [RoomStatus] status # @return [RoomInstance] Updated RoomInstance def update( status: nil ) data = Twilio::Values.of({ 'Status' => status, }) payload = @version.update('POST', @uri, data: data) RoomInstance.new( @version, payload, sid: @solution[:sid], ) end ## # Access the recording_rules # @return [RecordingRulesList] # @return [RecordingRulesContext] def recording_rules unless @recording_rules @recording_rules = RecordingRulesList.new( @version, room_sid: @solution[:sid], ) end @recording_rules end ## # Access the participants # @return [ParticipantList] # @return [ParticipantContext] if sid was passed. def participants(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return ParticipantContext.new(@version, @solution[:sid],sid ) end unless @participants @participants = ParticipantList.new( @version, room_sid: @solution[:sid], ) end @participants end ## # Access the recordings # @return [RoomRecordingList] # @return [RoomRecordingContext] if sid was passed. def recordings(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return RoomRecordingContext.new(@version, @solution[:sid],sid ) end unless @recordings @recordings = RoomRecordingList.new( @version, room_sid: @solution[:sid], ) end @recordings end ## # Provide a user friendly representation def to_s context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') "#" end ## # Provide a detailed, user friendly representation def inspect context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') "#" end end class RoomPage < Page ## # Initialize the RoomPage # @param [Version] version Version that contains the resource # @param [Response] response Response from the API # @param [Hash] solution Path solution for the resource # @return [RoomPage] RoomPage def initialize(version, response, solution) super(version, response) # Path Solution @solution = solution end ## # Build an instance of RoomInstance # @param [Hash] payload Payload response from the API # @return [RoomInstance] RoomInstance def get_instance(payload) RoomInstance.new(@version, payload) end ## # Provide a user friendly representation def to_s '' end end class RoomInstance < InstanceResource ## # Initialize the RoomInstance # @param [Version] version Version that contains the resource # @param [Hash] payload payload that contains response from Twilio # @param [String] account_sid The SID of the # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Room # resource. # @param [String] sid The SID of the Call resource to fetch. # @return [RoomInstance] RoomInstance def initialize(version, payload , sid: nil) super(version) # Marshaled Properties @properties = { 'sid' => payload['sid'], 'status' => payload['status'], 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']), 'account_sid' => payload['account_sid'], 'enable_turn' => payload['enable_turn'], 'unique_name' => payload['unique_name'], 'status_callback' => payload['status_callback'], 'status_callback_method' => payload['status_callback_method'], 'end_time' => Twilio.deserialize_iso8601_datetime(payload['end_time']), 'duration' => payload['duration'] == nil ? payload['duration'] : payload['duration'].to_i, 'type' => payload['type'], 'max_participants' => payload['max_participants'] == nil ? payload['max_participants'] : payload['max_participants'].to_i, 'max_participant_duration' => payload['max_participant_duration'] == nil ? payload['max_participant_duration'] : payload['max_participant_duration'].to_i, 'max_concurrent_published_tracks' => payload['max_concurrent_published_tracks'] == nil ? payload['max_concurrent_published_tracks'] : payload['max_concurrent_published_tracks'].to_i, 'record_participants_on_connect' => payload['record_participants_on_connect'], 'video_codecs' => payload['video_codecs'], 'media_region' => payload['media_region'], 'audio_only' => payload['audio_only'], 'empty_room_timeout' => payload['empty_room_timeout'] == nil ? payload['empty_room_timeout'] : payload['empty_room_timeout'].to_i, 'unused_room_timeout' => payload['unused_room_timeout'] == nil ? payload['unused_room_timeout'] : payload['unused_room_timeout'].to_i, 'large_room' => payload['large_room'], 'url' => payload['url'], 'links' => payload['links'], } # Context @instance_context = nil @params = { 'sid' => sid || @properties['sid'] , } end ## # Generate an instance context for the instance, the context is capable of # performing various actions. All instance actions are proxied to the context # @return [RoomContext] CallContext for this CallInstance def context unless @instance_context @instance_context = RoomContext.new(@version , @params['sid']) end @instance_context end ## # @return [String] The unique string that we created to identify the Room resource. def sid @properties['sid'] end ## # @return [RoomStatus] def status @properties['status'] end ## # @return [Time] The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. def date_created @properties['date_created'] end ## # @return [Time] The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. def date_updated @properties['date_updated'] end ## # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Room resource. def account_sid @properties['account_sid'] end ## # @return [Boolean] Deprecated, now always considered to be true. def enable_turn @properties['enable_turn'] end ## # @return [String] An application-defined string that uniquely identifies the resource. It can be used as a `room_sid` in place of the resource's `sid` in the URL to address the resource, assuming it does not contain any [reserved characters](https://tools.ietf.org/html/rfc3986#section-2.2) that would need to be URL encoded. This value is unique for `in-progress` rooms. SDK clients can use this name to connect to the room. REST API clients can use this name in place of the Room SID to interact with the room as long as the room is `in-progress`. def unique_name @properties['unique_name'] end ## # @return [String] The URL we call using the `status_callback_method` to send status information to your application on every room event. See [Status Callbacks](https://www.twilio.com/docs/video/api/status-callbacks) for more info. def status_callback @properties['status_callback'] end ## # @return [String] The HTTP method we use to call `status_callback`. Can be `POST` or `GET` and defaults to `POST`. def status_callback_method @properties['status_callback_method'] end ## # @return [Time] The UTC end time of the room in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#UTC) format. def end_time @properties['end_time'] end ## # @return [String] The duration of the room in seconds. def duration @properties['duration'] end ## # @return [RoomType] def type @properties['type'] end ## # @return [String] The maximum number of concurrent Participants allowed in the room. def max_participants @properties['max_participants'] end ## # @return [String] The maximum number of seconds a Participant can be connected to the room. The maximum possible value is 86400 seconds (24 hours). The default is 14400 seconds (4 hours). def max_participant_duration @properties['max_participant_duration'] end ## # @return [String] The maximum number of published audio, video, and data tracks all participants combined are allowed to publish in the room at the same time. Check [Programmable Video Limits](https://www.twilio.com/docs/video/programmable-video-limits) for more details. If it is set to 0 it means unconstrained. def max_concurrent_published_tracks @properties['max_concurrent_published_tracks'] end ## # @return [Boolean] Whether to start recording when Participants connect. ***This feature is not available in `peer-to-peer` rooms.*** def record_participants_on_connect @properties['record_participants_on_connect'] end ## # @return [Array] An array of the video codecs that are supported when publishing a track in the room. Can be: `VP8` and `H264`. ***This feature is not available in `peer-to-peer` rooms*** def video_codecs @properties['video_codecs'] end ## # @return [String] The region for the media server in Group Rooms. Can be: one of the [available Media Regions](https://www.twilio.com/docs/video/ip-addresses#media-servers). ***This feature is not available in `peer-to-peer` rooms.*** def media_region @properties['media_region'] end ## # @return [Boolean] When set to true, indicates that the participants in the room will only publish audio. No video tracks will be allowed. Group rooms only. def audio_only @properties['audio_only'] end ## # @return [String] Specifies how long (in minutes) a room will remain active after last participant leaves. Can be configured when creating a room via REST API. For Ad-Hoc rooms this value cannot be changed. def empty_room_timeout @properties['empty_room_timeout'] end ## # @return [String] Specifies how long (in minutes) a room will remain active if no one joins. Can be configured when creating a room via REST API. For Ad-Hoc rooms this value cannot be changed. def unused_room_timeout @properties['unused_room_timeout'] end ## # @return [Boolean] Indicates if this is a large room. def large_room @properties['large_room'] end ## # @return [String] The absolute URL of the resource. def url @properties['url'] end ## # @return [Hash] The URLs of related resources. def links @properties['links'] end ## # Fetch the RoomInstance # @return [RoomInstance] Fetched RoomInstance def fetch context.fetch end ## # Update the RoomInstance # @param [RoomStatus] status # @return [RoomInstance] Updated RoomInstance def update( status: nil ) context.update( status: status, ) end ## # Access the recording_rules # @return [recording_rules] recording_rules def recording_rules context.recording_rules end ## # Access the participants # @return [participants] participants def participants context.participants end ## # Access the recordings # @return [recordings] recordings def recordings context.recordings end ## # Provide a user friendly representation def to_s values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") "" end ## # Provide a detailed, user friendly representation def inspect values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") "" end end end end end end