Class: Wowza::REST::StreamGroup

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ StreamGroup

Returns a new instance of StreamGroup.



25
26
27
28
# File 'lib/wowza/rest/stream_group.rb', line 25

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_group.rb', line 7

def app_id
  @app_id
end

#connObject

Returns the value of attribute conn.



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

def conn
  @conn
end

#instance_nameObject

Returns the value of attribute instance_name.



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

def instance_name
  @instance_name
end

#is_transcode_resultObject

Returns the value of attribute is_transcode_result.



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

def is_transcode_result
  @is_transcode_result
end

#membersObject

Returns the value of attribute members.



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

def members
  @members
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#server_nameObject

Returns the value of attribute server_name.



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

def server_name
  @server_name
end

#stream_nameObject

Returns the value of attribute stream_name.



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

def stream_name
  @stream_name
end

#vhost_nameObject

Returns the value of attribute vhost_name.



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

def vhost_name
  @vhost_name
end

Class Method Details

.deserialize(attrs) ⇒ Object



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

def self.deserialize(attrs)
  attrs = attrs.with_indifferent_access
  {
    name: attrs["groupName"],
    is_transcode_result: attrs["isTranscodeResult"],
    instance_name: attrs["instanceName"],
    server_name: attrs["serverName"],
    members: attrs["members"],
  }
end

.find_by(attrs) ⇒ Object



21
22
23
# File 'lib/wowza/rest/stream_group.rb', line 21

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

Instance Method Details

#application_pathObject



97
98
99
# File 'lib/wowza/rest/stream_group.rb', line 97

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

#attributesObject



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

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

#connected?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/wowza/rest/stream_group.rb', line 43

def connected?
  is_connected
end

#idObject



109
110
111
# File 'lib/wowza/rest/stream_group.rb', line 109

def id
  name
end

#instance_pathObject



105
106
107
# File 'lib/wowza/rest/stream_group.rb', line 105

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

#is_connectedObject



39
40
41
# File 'lib/wowza/rest/stream_group.rb', line 39

def is_connected
  @is_connected || false
end

#is_recordingObject



47
48
49
# File 'lib/wowza/rest/stream_group.rb', line 47

def is_recording
  @is_recording || false
end

#recording?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/wowza/rest/stream_group.rb', line 51

def recording?
  is_recording
end

#reload!Object



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

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

#resource_pathObject



73
74
75
# File 'lib/wowza/rest/stream_group.rb', line 73

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

#server_pathObject



81
82
83
# File 'lib/wowza/rest/stream_group.rb', line 81

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

#streamsObject



113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/wowza/rest/stream_group.rb', line 113

def streams
  (members || []).map do |stream_name|
    Stream.new({
      name: stream_name,
      app_id: app_id,
      server_name: server_name,
      vhost_name: vhost_name,
      instance_name: instance_name,
      conn: conn
    })
  end
end

#vhost_pathObject



89
90
91
# File 'lib/wowza/rest/stream_group.rb', line 89

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