wowza_rest 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/lib/wowza_rest/applications.rb +7 -4
- data/lib/wowza_rest/client.rb +3 -1
- data/lib/wowza_rest/data/application.rb +46 -13
- data/lib/wowza_rest/data/base.rb +55 -6
- data/lib/wowza_rest/data/incoming_stream_stats.rb +1 -0
- data/lib/wowza_rest/data/instance.rb +6 -4
- data/lib/wowza_rest/data/server_status.rb +6 -0
- data/lib/wowza_rest/version.rb +1 -1
- data/wowza_rest.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f37ae4846ac5b847a83ea42ac030d41d11fa3509
|
4
|
+
data.tar.gz: c81253f1e3ae7178cc3502a028aa18726e128629
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b3fd80dd0f150d059644a768177bbe96eddb31515398fdabb24a5784b9fbcf2506dd5b674c39f66d5c0c54b3be31500b264f3ba46c0671d86c51412a72361e6
|
7
|
+
data.tar.gz: 283939b6c666974a600dd701c97da58e6e2c69526608649bd7259c149bf824b7f2bc09c3af08b85995681acc49bd61fdef8c7a4c2c15ce72f713dd26b5edb0a6
|
data/.rubocop.yml
CHANGED
@@ -45,19 +45,22 @@ module WowzaRest
|
|
45
45
|
private
|
46
46
|
|
47
47
|
# rubocop:disable Metrics/LineLength
|
48
|
+
# rubocop:disable Metrics/MethodLength
|
48
49
|
def apply_update_application_checks(app_name, config)
|
49
50
|
if !app_name.is_a?(String)
|
50
51
|
raise WowzaRest::Errors::InvalidArgumentType,
|
51
52
|
"First argument expected to be String got #{app_name.class} instead"
|
52
|
-
elsif !config.is_a?(Hash)
|
53
|
+
elsif !config.is_a?(Hash) && !config.is_a?(WowzaRest::Data::Application)
|
53
54
|
raise WowzaRest::Errors::InvalidArgumentType,
|
54
|
-
"Second argument expected to be
|
55
|
-
|
55
|
+
"Second argument expected to be Hash or WowzaRest::Data::Application instance,
|
56
|
+
got #{config.class} instead"
|
57
|
+
elsif config.is_a?(Hash) && config.empty?
|
56
58
|
raise WowzaRest::Errors::InvalidArgument,
|
57
|
-
'Configuration hash must
|
59
|
+
'When Configuration passeed as hash it must contains at least one attribute'
|
58
60
|
end
|
59
61
|
end
|
60
62
|
# rubocop:enable Metrics/LineLength
|
63
|
+
# rubocop:enable Metrics/MethodLength
|
61
64
|
|
62
65
|
# rubocop:disable Metrics/MethodLength
|
63
66
|
# rubocop:disable Metrics/LineLength
|
data/lib/wowza_rest/client.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'wowza_rest/api'
|
2
2
|
require 'wowza_rest/connection'
|
3
3
|
require 'wowza_rest/errors'
|
4
|
+
require_relative 'data/server_status'
|
4
5
|
|
5
6
|
module WowzaRest
|
6
7
|
class Client
|
@@ -20,7 +21,8 @@ module WowzaRest
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def server_status
|
23
|
-
connection.request(:get, '/status', base_uri: server_path)
|
24
|
+
response = connection.request(:get, '/status', base_uri: server_path)
|
25
|
+
WowzaRest::Data::ServerStatus.new(response.parsed_response)
|
24
26
|
rescue
|
25
27
|
nil
|
26
28
|
end
|
@@ -7,20 +7,22 @@ module WowzaRest
|
|
7
7
|
:drm_config, :transcoder_config, :modules
|
8
8
|
|
9
9
|
def initialize(attrs = {})
|
10
|
-
|
10
|
+
keys_reader :securityConfig, :streamConfig, :dvrConfig,
|
11
|
+
:drmConfig, :transcoderConfig, :modules
|
12
|
+
initialize_object_attrs(attrs || {})
|
11
13
|
super(attrs)
|
12
14
|
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
def to_h
|
17
|
+
super() do |k, arr|
|
18
|
+
if k == :@modules
|
19
|
+
{
|
20
|
+
moduleList: objects_array_to_hash_array(arr)
|
21
|
+
}
|
22
|
+
else
|
23
|
+
objects_array_to_hash_array(arr)
|
24
|
+
end
|
21
25
|
end
|
22
|
-
|
23
|
-
class Template < Base; end
|
24
26
|
end
|
25
27
|
|
26
28
|
class SecurityConfig < Base; end
|
@@ -29,9 +31,43 @@ module WowzaRest
|
|
29
31
|
class DRMConfig < Base; end
|
30
32
|
class Module < Base; end
|
31
33
|
|
34
|
+
class TranscoderConfig < Base
|
35
|
+
attr_reader :templates
|
36
|
+
|
37
|
+
def initialize(attrs = {})
|
38
|
+
if !attrs.nil? && attrs['templates']
|
39
|
+
keys_reader :templates
|
40
|
+
@templates = wrap_array_objects(
|
41
|
+
attrs.delete('templates')['templates'], Template
|
42
|
+
)
|
43
|
+
end
|
44
|
+
super(attrs)
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_h
|
48
|
+
super() do |k, arr|
|
49
|
+
if k == :@templates
|
50
|
+
{
|
51
|
+
templates: objects_array_to_hash_array(arr)
|
52
|
+
}
|
53
|
+
else
|
54
|
+
objects_array_to_hash_array(arr)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class Template < Base; end
|
60
|
+
end
|
61
|
+
|
32
62
|
private
|
33
63
|
|
64
|
+
# rubocop:disable Metrics/MethodLength
|
34
65
|
def initialize_object_attrs(attrs)
|
66
|
+
if attrs['modules']
|
67
|
+
@modules = wrap_array_objects(
|
68
|
+
attrs.delete('modules')['moduleList'], Module
|
69
|
+
)
|
70
|
+
end
|
35
71
|
@security_config = SecurityConfig.new(attrs.delete('securityConfig'))
|
36
72
|
@stream_config = StreamConfig.new(attrs.delete('streamConfig'))
|
37
73
|
@dvr_config = DVRConfig.new(attrs.delete('dvrConfig'))
|
@@ -39,9 +75,6 @@ module WowzaRest
|
|
39
75
|
@transcoder_config = TranscoderConfig.new(
|
40
76
|
attrs.delete('transcoderConfig')
|
41
77
|
)
|
42
|
-
@modules = map_array_objects(
|
43
|
-
attrs.delete('modules')['moduleList'], Module
|
44
|
-
)
|
45
78
|
end
|
46
79
|
end
|
47
80
|
end
|
data/lib/wowza_rest/data/base.rb
CHANGED
@@ -2,14 +2,15 @@ module WowzaRest
|
|
2
2
|
module Data
|
3
3
|
class Base
|
4
4
|
def initialize(attrs = {})
|
5
|
-
setup_attributes(attrs)
|
5
|
+
setup_attributes(attrs || {})
|
6
6
|
end
|
7
7
|
|
8
8
|
def setup_attributes(attrs)
|
9
9
|
attrs.each do |k, v|
|
10
|
-
define_attribute_getter(k.underscore)
|
11
|
-
define_attribute_setter(k.underscore)
|
12
|
-
|
10
|
+
define_attribute_getter(k.to_s.underscore)
|
11
|
+
define_attribute_setter(k.to_s.underscore)
|
12
|
+
define_key_getter(k.to_s)
|
13
|
+
instance_variable_set("@#{k.to_s.underscore}", v)
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
@@ -25,8 +26,56 @@ module WowzaRest
|
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
def
|
29
|
-
|
29
|
+
def define_key_getter(key)
|
30
|
+
define_singleton_method("#{key.underscore}_key") do
|
31
|
+
key.to_s
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def keys_reader(*args)
|
36
|
+
args.each do |arg|
|
37
|
+
define_key_getter(arg.to_s)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def wrap_array_objects(arr, klass)
|
42
|
+
arr.map { |obj| klass.new(obj) } unless arr.nil?
|
43
|
+
end
|
44
|
+
|
45
|
+
def objects_array_to_hash_array(arr)
|
46
|
+
return if arr.nil?
|
47
|
+
arr.map do |obj|
|
48
|
+
obj.is_a?(WowzaRest::Data::Base) ? obj.to_h : obj
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# rubocop:disable Metrics/MethodLength
|
53
|
+
def to_h
|
54
|
+
instance_variables.each_with_object({}) do |var, hash|
|
55
|
+
value = instance_variable_get(var)
|
56
|
+
hash[send("#{var.to_s.delete('@')}_key")] =
|
57
|
+
if value.is_a?(WowzaRest::Data::Base)
|
58
|
+
instance_variable_get(var).to_h
|
59
|
+
elsif value.is_a?(Array)
|
60
|
+
if block_given?
|
61
|
+
yield(var, instance_variable_get(var))
|
62
|
+
else
|
63
|
+
objects_array_to_hash_array(instance_variable_get(var))
|
64
|
+
end
|
65
|
+
else
|
66
|
+
instance_variable_get(var)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
# rubocop:enable Metrics/MethodLength
|
71
|
+
alias to_hash to_h
|
72
|
+
|
73
|
+
def to_json
|
74
|
+
to_h.to_json
|
75
|
+
end
|
76
|
+
|
77
|
+
def include?(attr_name)
|
78
|
+
to_h.include?(attr_name.to_s)
|
30
79
|
end
|
31
80
|
end
|
32
81
|
end
|
@@ -8,16 +8,18 @@ module WowzaRest
|
|
8
8
|
|
9
9
|
# rubocop:disable Metrics/MethodLength
|
10
10
|
def initialize(attrs = {})
|
11
|
-
|
11
|
+
keys_reader :incomingStreams, :outgoingStreams,
|
12
|
+
:recorders, :streamGroups
|
13
|
+
@incoming_streams = wrap_array_objects(
|
12
14
|
attrs.delete('incomingStreams'), IncomingStream
|
13
15
|
)
|
14
|
-
@outgoing_streams =
|
16
|
+
@outgoing_streams = wrap_array_objects(
|
15
17
|
attrs.delete('outgoingStreams'), OutgoingStream
|
16
18
|
)
|
17
|
-
@recorders =
|
19
|
+
@recorders = wrap_array_objects(
|
18
20
|
attrs.delete('recorders'), Recorder
|
19
21
|
)
|
20
|
-
@stream_groups =
|
22
|
+
@stream_groups = wrap_array_objects(
|
21
23
|
attrs.delete('streamGroups'), StreamGroup
|
22
24
|
)
|
23
25
|
super(attrs)
|
data/lib/wowza_rest/version.rb
CHANGED
data/wowza_rest.gemspec
CHANGED
@@ -40,6 +40,7 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.add_development_dependency 'dotenv'
|
41
41
|
spec.add_development_dependency 'rubocop'
|
42
42
|
spec.add_development_dependency 'rubocop-rspec'
|
43
|
+
spec.add_development_dependency 'rspec-json_expectations'
|
43
44
|
|
44
45
|
spec.add_dependency 'httparty'
|
45
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wowza_rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hazem Taha
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec-json_expectations
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: httparty
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,6 +193,7 @@ files:
|
|
179
193
|
- lib/wowza_rest/data/base.rb
|
180
194
|
- lib/wowza_rest/data/incoming_stream_stats.rb
|
181
195
|
- lib/wowza_rest/data/instance.rb
|
196
|
+
- lib/wowza_rest/data/server_status.rb
|
182
197
|
- lib/wowza_rest/errors.rb
|
183
198
|
- lib/wowza_rest/instances.rb
|
184
199
|
- lib/wowza_rest/publishers.rb
|