Class: Wowza::REST::Stream

Inherits:
Object
  • Object
show all
Includes:
Assignment::Attributes
Defined in:
lib/wowza/rest/stream.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Stream

Returns a new instance of Stream.



24
25
26
27
# File 'lib/wowza/rest/stream.rb', line 24

def initialize(attributes={})
  assign_attributes(attributes) if attributes
  super()
end

Instance Attribute Details

#app_idObject

Returns the value of attribute app_id.



7
8
9
# File 'lib/wowza/rest/stream.rb', line 7

def app_id
  @app_id
end

#connObject

Returns the value of attribute conn.



7
8
9
# File 'lib/wowza/rest/stream.rb', line 7

def conn
  @conn
end

#instance_nameObject

Returns the value of attribute instance_name.



7
8
9
# File 'lib/wowza/rest/stream.rb', line 7

def instance_name
  @instance_name
end

#is_connectedObject

Returns the value of attribute is_connected.



7
8
9
# File 'lib/wowza/rest/stream.rb', line 7

def is_connected
  @is_connected
end

#is_recordingObject

Returns the value of attribute is_recording.



7
8
9
# File 'lib/wowza/rest/stream.rb', line 7

def is_recording
  @is_recording
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/wowza/rest/stream.rb', line 7

def name
  @name
end

#server_nameObject

Returns the value of attribute server_name.



7
8
9
# File 'lib/wowza/rest/stream.rb', line 7

def server_name
  @server_name
end

#source_ipObject

Returns the value of attribute source_ip.



7
8
9
# File 'lib/wowza/rest/stream.rb', line 7

def source_ip
  @source_ip
end

#vhost_nameObject

Returns the value of attribute vhost_name.



7
8
9
# File 'lib/wowza/rest/stream.rb', line 7

def vhost_name
  @vhost_name
end

Class Method Details

.deserialize(attrs) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/wowza/rest/stream.rb', line 10

def self.deserialize(attrs)
  attrs = attrs.with_indifferent_access
  {
    name: attrs["name"],
    is_connected: attrs["isConnected"],
    is_recording: attrs["isRecordingSet"],
    source_ip: attrs["sourceIp"],
  }
end

.find_by(attrs) ⇒ Object



20
21
22
# File 'lib/wowza/rest/stream.rb', line 20

def self.find_by(attrs)
  new(attrs).reload!
end

Instance Method Details

#application_pathObject



91
92
93
# File 'lib/wowza/rest/stream.rb', line 91

def application_path
  "#{vhost_path}/applications/#{app_id}"
end

#attributesObject



29
30
31
32
33
34
35
36
# File 'lib/wowza/rest/stream.rb', line 29

def attributes
  {
    name: name,
    is_connected: is_connected,
    is_recording: is_recording,
    source_ip: source_ip
  }
end

#connected?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/wowza/rest/stream.rb', line 42

def connected?
  is_connected
end

#idObject



103
104
105
# File 'lib/wowza/rest/stream.rb', line 103

def id
  name
end

#instance_pathObject



99
100
101
# File 'lib/wowza/rest/stream.rb', line 99

def instance_path
  "#{application_path}/instances/#{instance_name}"
end

#recording?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/wowza/rest/stream.rb', line 50

def recording?
  is_recording
end

#reload!Object



54
55
56
57
58
59
# File 'lib/wowza/rest/stream.rb', line 54

def reload!
  resp = conn.get resource_path
  attrs = JSON.parse(resp.body)
  assign_attributes(self.class.deserialize(attrs)) if attrs
  self
end

#resource_pathObject



67
68
69
# File 'lib/wowza/rest/stream.rb', line 67

def resource_path
  "#{instance_path}/incomingstreams/#{id}"
end

#server_pathObject



75
76
77
# File 'lib/wowza/rest/stream.rb', line 75

def server_path
  "/v2/servers/#{server_name}"
end

#vhost_pathObject



83
84
85
# File 'lib/wowza/rest/stream.rb', line 83

def vhost_path
  "#{server_path}/vhosts/#{vhost_name}"
end